Hello
Today I spent several hours on this case testing various optimizerr settings. Here are some results, I hope somebody has an idea
- The problem is related to the union, there are 4 queries "connected" with 3 union operators. If I run a single "union" it runs fast, when I add a second "union" the performance drops
1 union -> 1 sec
2 unions -> 44sec
3 unions -> 88sec
Each query alone is executed instantly
- All the unions are executed using "h_union_distinct" even if I have run
set hash_union_distinct off
and I see it in sp_options "show"
- I have the set "max parallel degree", "max scan parallel degree" on serverr but in sp_options I always see them as disabled. If I run a set command then parallelism is enabled, however not for the "union" query.
- I run "update statistics with hashing" for all tables, but it had no effect
- I experimented by setting on/off various options I see in sp_options without any result at all.
- I saw the missing stats and I added them, but again the query performs the same
Finally I run out of ideas on what to do