Go, go Query Store! Gail Shaw
The Query what? New in SQL 2016 / Azure db version 12 A ‘flight recorder’ for SQL Server queries Aggregated performance information and execution plan Persisted into the database
What magic is this? On compilation, the query and plan are stored in the Query Store When a query is recompiled, the new plan is sent to the Query Store If it’s a different plan to ones already in the Query Store, it’s added When query execution completes, run-time info is sent to the Query Store Data is written to disk in 15-minute intervals (configurable) Run time stats are aggregated, default 60 minutes
But, we’ve already got DMVs The run-time DMVs depend on a query having a plan in cache They don’t record queries run with any recompile setting They’re memory only. Query Store is persisted into the user database Doesn’t rely on plans still being in cache Is included in backups!
Ok, so how do I use it? SSMS 2016 has reports built in Or, lots of catalogue views sys.query_store_query sys.query_store_query_text sys.query_store_plan sys.query_store_runtime_stats sys.query_store_runtime_stats_interval
Uses for Query Store Upgrade tests Identify cases of parameter sniffing or other unstable plan problems Pinpoint the top resource consuming queries, without needing SQLTrace/XE
Further resources Monitoring performance using the Query Store - https://msdn.microsoft.com/en-us/library/dn817826.aspx How the Query Store collects data - https://msdn.microsoft.com/en- us/library/mt631173.aspx https://azure.microsoft.com/en-us/blog/query-store-a-flight-data- recorder-for-your-database/