Skip to content

Examples

Enrico van de Laar edited this page Dec 15, 2016 · 3 revisions

Using the sp_WhatsupQueryStore stored procedure is very easy! Just to get you started with using it, here are some examples:

Return all information windows

EXEC sp_WhatsupQueryStore @dbname='database name', @return_all=1

By running the command above, sp_WhatsupQueryStore will return all information windows for the database 'database name'. Returning all the information sp_WhatsupQueryStore can grab from the Query Store can take some time depending on the size and activity of the Query Store you are running it against.

Return the top 10 queries based on average duration in the last 4 hours

EXEC sp_WhatsupQueryStore @dbname='database name', @timewindow=4, @topqueries=10, @return_top_duration=1

This query limits the information returned to only the top 10 queries based on average duration executed in the last 4 hours.

Return forced execution plans and queries that have multiple execution plans

EXEC sp_WhatsupQueryStore @dbname='database name', @timewindow=2, @return_forced_plans=1, @return_multiple_plans=1

This query will return all the forced execution plans as well as all the queries that generated multiple execution plans in the last 2 hours.