| Start |
|---|
| Enable query store on database Query store can be enabled on database by using the following command: SQL Server/Azure SQL Database will collect information about executed queries and provide information in sys.query_store views:
|
| Get execution statistics for SQL queries/plans The following query will return informationa about qeries, their plans and average statistics regarding their duration, CPU time, physical and logical io reads. |
| Remove data from query store If you want to remove some query or query plan from query store, you can use the following commands: Parameters for these stored procedures are query/plan id retrieved from system views. You can also just remove execution statistics for particular plan without removing the plan from the store: Parameter provided to this procedure plan id. |
| Forcing plan for query 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: From this point, QO will always use plan provided for the query. If you want to remove this binding, you can use the following stored procedure: From this point, QO will again try to find the best plan. |
Read Article
https://develop.horje.com/learn/1434/reference