Tutorial by Examples

Query store can be enabled on database by using the following command: ALTER DATABASE tpch SET QUERY_STORE = ON SQL Server/Azure SQL Database will collect information about executed queries and provide information in sys.query_store views: sys.query_store_query sys.query_store_query_text sy...
The following query will return informationa about qeries, their plans and average statistics regarding their duration, CPU time, physical and logical io reads. SELECT Txt.query_text_id, Txt.query_sql_text, Pl.plan_id, avg_duration, avg_cpu_time, avg_physical_io_reads, avg_logica...
If you want to remove some query or query plan from query store, you can use the following commands: EXEC sp_query_store_remove_query 4; EXEC sp_query_store_remove_plan 3; Parameters for these stored procedures are query/plan id retrieved from system views. You can also just remove execution ...
SQL Query optimizer will choose the baes possible plan that he can find for some query. If you can find some plan that works optimally for some query, you can force QO to always use that plan using the following stored procedure: EXEC sp_query_store_unforce_plan @query_id, @plan_id From this poi...

Page 1 of 1