One of the queries I use the most, is the pplan-cache query from this post:
Simple query to check the recent performance history
The good thing about the query is that it shows information that could otherwise require a lot of work (collecting and analysing traces files). And the query does not need any advance work or setup. It can just be run. So it's a very easy way to receive information from a system, which is often very useful as a first step in troubleshooting performance. For more details about the result of the query, refer to the post linked above.
Below is a slightly enhanced version of the query. Since the query is based on the cache of compiled query plans, it is not a big step to extend it to also include the query plan itself, and even extract certain information from the plan if you know what you are looking for.
So this query does the same as the original one, but with the following additions:
Here is the updated query
SELECT
execution_count
last_logical_reads
min_logical_reads
max_logical_reads
plan_handle
ph
-- Query Plan Information
then '' else
end
FROM
CROSS
ORDER
What I would really like, is to receive feedback on what parts of the query plans are useful. Then extend the query even further to include as much useful information as possible. For exdample, in some cases the query plan contains missing index-information. The lines below can be copied into the query above to include this information. Any feedback on whether this is useful or not, and whether other information from the query plans can be useful is really very welcome. You can add comments about this below.
,
then
else
case
Lars Lohndorf-Larsen
Escalation Engineer
These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.