Commit 48315e8
Add @pause_milliseconds batch pacing to sp_QueryStoreCleanup
The removal cursor calls sys.sp_query_store_remove_query once per
query_id back-to-back. On a bulk purge of tens of thousands of
queries that hammers Query Store's internal writes and blocks
concurrent QS writers without relief.
Added @pause_milliseconds (integer, default 0). When > 0, the cursor
sleeps that many ms after each remove via WAITFOR DELAY. Clamped to
[0, 60000] so a fat-finger doesn't produce a multi-hour run.
The delay string is built once per execution as hh:mm:ss.mmm (style
114) from DATEADD(MILLISECOND, @pause_milliseconds, '00:00:00') —
verified both 100 and 60000 render correctly and WAITFOR accepts
the string.
@pause_milliseconds = 0 (default) preserves the existing no-sleep
behavior. Help text and parameter metadata updated to match.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1057e2b commit 48315e8
1 file changed
Lines changed: 41 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
96 | 97 | | |
97 | 98 | | |
98 | 99 | | |
| 100 | + | |
| 101 | + | |
99 | 102 | | |
100 | 103 | | |
101 | 104 | | |
| |||
120 | 123 | | |
121 | 124 | | |
122 | 125 | | |
| 126 | + | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| |||
144 | 149 | | |
145 | 150 | | |
146 | 151 | | |
| 152 | + | |
| 153 | + | |
147 | 154 | | |
148 | 155 | | |
149 | 156 | | |
| |||
939 | 946 | | |
940 | 947 | | |
941 | 948 | | |
| 949 | + | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
942 | 978 | | |
943 | 979 | | |
944 | 980 | | |
| |||
963 | 999 | | |
964 | 1000 | | |
965 | 1001 | | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
966 | 1007 | | |
967 | 1008 | | |
968 | 1009 | | |
| |||
0 commit comments