问题
I have tried to display the actual execution plan of a stored procedure as I posted here. There are 17 queries in total and here is the part of execution plan of the last query. This query is more complicated than others, because the execution time will be much shorter if I remove this part.
For query 17, five "select" statements are unioned together and distinct rows are selected from the combined set.
I am new to this SQL part and I am curious that:
- why the query cost of query 17 is so low, but it actually takes the most execution time;
- there are five highlighted blocks which took about 50s to complete, but their cost is also very low;
- the total execution time 1 min 59 sec, however sum of the five blocks is about 4 min;
- not sure if I have provided enough info, but are there any ways to improve this stored procedure? I have added non-clustered index to help, but it seems the index has not been used.
来源:https://stackoverflow.com/questions/62763249/how-to-analyze-actual-execution-plan-and-create-non-clustered-index-to-help-the