can be wrong, where is a better place to retrieve the correct one? The best places to get execution plan information are:
1. dm_exec_query_plan() or dm_exec_text_query_plan() – contains raw data for execution plans of SQL statements. It provides the plan SQL Server used so why not go straight to the source. Using dm_exec_query_plan from SSMS will provide a nice graphical view of the plan. To use this DMO, pass in the plan_handle value from the query above against the dm_exec_requests DMV.
2. Tracing – provides great information as well as executions plans for a specific session, user or the entire system.
3. Historical Data – if possible, collect and save execution plan information so you can go back to 3:00 pm yesterday to understand why the SQL statement performed poorly.
DPA for SQL Server collects execution plans in real time and associates them with the SQL statements, wait types and other performance data. It is shown graphically with popup dialogs when mousing over specific steps in the plan. DPA also keeps this data historically so you can go back to the problem at 3:00 pm to find exactly which plan was being used. Querying plans from the DMVs or getting them from tracing will not provide this historical view.
Not all plans are created equal
Here is an example where, based on response time data, we believed the query was doing a full table scan since the SQL was spending over 95% of its execution time waiting for PAGEIOLATCH_SH and the logical and physical reads were very high per execution. However, when we reviewed the plan output from SSMS, the query looked very efficient and seemed to be using an index to retrieve the data. Here is the statement and the plan: