Skip to content

Commit 9d03cc9

Browse files
sp_QuickieCache: add CPU tie-breaker to duplicate plans sort order
Within the same plan_count, sort by total_worker_time DESC so the most expensive query hash surfaces first. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 99deded commit 9d03cc9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sp_QuickieCache/sp_QuickieCache.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
498498
HAVING
499499
COUNT_BIG(DISTINCT qs.plan_handle) > 1
500500
ORDER BY
501-
COUNT_BIG(DISTINCT qs.plan_handle) DESC
501+
COUNT_BIG(DISTINCT qs.plan_handle) DESC,
502+
SUM(qs.total_worker_time) DESC
502503
OPTION(RECOMPILE, MAXDOP 1);
503504

504505
RETURN;

0 commit comments

Comments
 (0)