From 52cb3dc3b4b9f78d87b869cd1b1f50ea1ab00a08 Mon Sep 17 00:00:00 2001 From: tpp <146148086+terry1purcell@users.noreply.github.com> Date: Tue, 18 Nov 2025 03:29:35 -0800 Subject: [PATCH] planner: bug fix for compareCandidates (#64525) ref pingcap/tidb#64378 --- pkg/planner/core/find_best_task.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/planner/core/find_best_task.go b/pkg/planner/core/find_best_task.go index db5575dd4b..ea8564e325 100644 --- a/pkg/planner/core/find_best_task.go +++ b/pkg/planner/core/find_best_task.go @@ -918,7 +918,7 @@ func compareCandidates(sctx base.PlanContext, statsTbl *statistics.Table, prop * if riskResult > 0 && leftDidNotLose && totalSum >= 0 && predicateResult > 1 { return 1, lhsPseudo // left wins - also return whether it has statistics (pseudo) or not } - if riskResult < 0 && rightDidNotLose && totalSum <= 0 && predicateResult < 1 { + if riskResult < 0 && rightDidNotLose && totalSum <= 0 && predicateResult < -1 { return -1, rhsPseudo // right wins - also return whether it has statistics (pseudo) or not } return 0, false // No winner (0). Do not return the pseudo result