Execution plans tell SQL Server how to execute queries. If you listen closely, execution plans can also tell you when performance-tuning opportunities exist in your environment. By listening to your queries, you can understand how SQL Server is operating and gain insight into how your environment is functioning. In this session, learn how to use XQuery to browse and search the plan cache, enabling you to find potential performance issues and opportunities to tune your queries. In addition, learn how a performance issue on a single execution plan can be used to find similar issues on other execution plans, enabling you to scale up your performance tuning effectiveness. You can use this information to help reduce issues related to parallelism, shift queries from using scans to using seek operations, or discover exactly which queries are using which indexes. All this and more is readily available through the plan cache.
11. What is the plan cache?
• SQL Server memory
• Stores execution plans
• From Query Optimizer
• Used to execute SQL statements.
12. Plan Cache
sys.dm_exec_cached_plans
• All Plans
• Size
• Use count
sys.dm_exec_query_plan
• Table Valued Function
• SHOWPLAN XML as XML
sys.dm_exec_text_query_plan
• Table Valued Function
• SHOWPLAN XML as text
13. Plan Handle
sys.dm_exec_requests
• Current connection
• Vaguely similar to sp_who
sys.dm_exec_query_stats
• Stats on executed queries
• Contains SQL_Handle
sys.dm_exec_cached_plans
• Stats on cached plans
• Distinct list of plans
19. Relational Operators
Activities within execution plan
• Clustered Index Scan
• Merge Join
• Compute Scalar
• Filter
Describe the operation
Both logical and physical
22. What do I need?
Where am I using it?
Quality vs. Quantity?
Indexing Problems
23. Missing index DMVs
• sys.dm_db_missing_index_columns
• sys.dm_db_missing_index_details
• sys.dm_db_missing_index_group_stats
• sys.dm_db_missing_index_groups
What queries do you test?
What do I need?
http://www.flickr.com/photos/fallentomato/3918329246/
24. Increasing index scans?
How do you correlate perf stats?
• Access Methods:Full Scans/sec
Dynamic management view
• sys.dm_db_index_usage_stats
• sys.dm_db_index_operational_stats
Where am I using it?
25. What plans are using an index?
• What is the potential effect?
• Does it impact any critical processes?
• Should you drop it?
Quality vs. Quantity?
25
31. Your Call To Action
Be creative in using your
performance tuning knowledge
Think of performance issues as
patterns
Always prioritize your performance
tuning efforts
32. 32
Explore Everything PASS Has to Offer
FREE ONLINE WEBINAR EVENTS FREE 1-DAY LOCAL TRAINING EVENTS
LOCAL USER GROUPS
AROUND THE WORLD
ONLINE SPECIAL INTEREST
USER GROUPS
BUSINESS ANALYTICS TRAINING
VOLUNTEERING OPPORTUNITIES
PASS COMMUNITY NEWSLETTER
BA INSIGHTS NEWSLETTERFREE ONLINE RESOURCES
33. 33
Session Evaluations
ways to access
Go to passSummit.com Download the GuideBook App
and search: PASS Summit 2015
Follow the QR code link displayed
on session signage throughout the
conference venue and in the
program guide
Submit by 5pm
Friday November 6th to
WIN prizes
Your feedback is
important and valuable.
http://www.cx.com.s3.amazonaws.com/img/wp/blog/slow-website.jpg
When I first started talking to people about querying the plan cache, it was about interesting things. But the more I’ve gotten into looking at the plan cache, I’ve found that the value is find slowly performing items and finding new ways to make that problem actionable.
https://s3-us-west-1.amazonaws.com/kout.io/whatyoudotoday_2880x1800.jpg
What I want to discuss today is how you take something you know and expand that to a more holistic view of your entire platform.
http://www.fastcompany.com/3037224/fast-feed/whispers-no-good-very-bad-day
So we’re going to look at how we can start talking differently to our SQL Server to better understand the problems it is encountering and how you can take different actions.
Some plans (bulk insert, no recompile) don’t exist in cache after execution
Pros
No setup
Query-able
Actionable
Real World
Cons
Reset with service
Activity flush
Plans miss cache
In Use