Skip to content
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

planner: notify skyline pruning of index statistics availability #59110

Merged
merged 3 commits into from
Jan 26, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add testcases
  • Loading branch information
terry1purcell committed Jan 22, 2025
commit 7401fb36df5ec18e40b39fe897636da5b618f4db
7 changes: 6 additions & 1 deletion pkg/planner/cardinality/selectivity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func TestNewIndexWithoutStats(t *testing.T) {
testKit := testkit.NewTestKit(t, store)
testKit.MustExec("use test")
testKit.MustExec("drop table if exists t")
testKit.MustExec("create table t(a int, b int, c int, index idxa(a))")
testKit.MustExec("create table t(a int, b int, c int, index idxa(a), index idxca(c,a))")
testKit.MustExec("set @@tidb_analyze_version=2")
testKit.MustExec("set @@global.tidb_enable_auto_analyze='OFF'")
testKit.MustExec("insert into t values (1, 1, 1)")
Expand All @@ -364,6 +364,11 @@ func TestNewIndexWithoutStats(t *testing.T) {
testKit.MustExec("create index idxab on t(a, b)")
// New index idxab should win due to having the most matching equal predicates - regardless of no statistics
testKit.MustQuery("explain format='brief' select * from t where a = 5 and b = 5").CheckContain("idxab(a, b)")
// New index idxab should win due to having the most predicates - regardless of no statistics
testKit.MustQuery("explain format='brief' select * from t where a > 5 and b > 5").CheckContain("idxab(a, b)")
testKit.MustQuery("explain format='brief' select * from t where a = 5 and b > 5 and c > 5").CheckContain("idxab(a, b)")
// New index idxab should NOT win because idxca has the same number of equals and has statistics
testKit.MustQuery("explain format='brief' select * from t where a = 5 and b > 5 and c = 5").CheckContain("idxca(c, a)")
}

func TestIssue57948(t *testing.T) {
Expand Down