-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue while running the [dbo].[QDSCacheCleanup] to purge Query Store #33
Comments
|
@SQLozano On running the @verbosemode = 1 on UAT server (where query store size is 1 GB) it seems to be running for a long time. However, I can see that it is performing some thing. Is there any way we can fasten this process up? |
I am having a similar issue and I think the problem is the performance of the Microsoft stored procedures that perform the cleanup, and not an issue with QDSCacheCleanup directly. As a guide it took 8 hours to clean up 186,639 queries (this was stats only cleanup as the default is incorrect in the comments of the stored procedure (see another issue I raised). sys.query_store_query = 1,346,106 I propose a new parameter (I suggest a default of 25,000 as that seems to be the tipping point for long execution times, so run time is about 1 hour based on my statistics): @MaxCleanupQueryCount INT = 25000 Plus a variable @CleanUpQueryCount to hold a counter that is incremented each loop. The Loop Condition is then updated to evaluate the new parameter: WHILE (SELECT COUNT(1) FROM #DeleteableQueryTable) > 0 AND (@MaxCleanupQueryCount = 0 OR @CleanUpQueryCount < @MaxCleanupQueryCount)
This will allow a fixed number of queries to be removed each time and prevent the long execution times. |
I picked up that this statement can take up to 300ms to run (each times it loops) with a high volume of data, so adding an index on [ForcedPlan] will help (it has in my testing):
|
Hi,
There is an issue while trying to purge Query store.
Ran below, and the proc is running for hours and it ran for more than 10 or 12 hours and finally I cancelled it.
Please advise if there is anything we can do to fix.
EXECUTE [dbo].[QDSCacheCleanup]
@DatabaseName = 'DB'
,@CleanAdhocStale = 0
,@CleanStale = 1
,@retention = 12
,@MinExecutionCount = 2
,@CleanOrphan = 1
,@CleanInternal = 1
,@CleanStatsOnly = 0
The text was updated successfully, but these errors were encountered: