How to analyze actual execution plan and create non-clustered index to help the query

久未见 提交于 2020-07-23 06:45:30

问题


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:

  1. why the query cost of query 17 is so low, but it actually takes the most execution time;
  2. there are five highlighted blocks which took about 50s to complete, but their cost is also very low;
  3. the total execution time 1 min 59 sec, however sum of the five blocks is about 4 min;
  4. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!