-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
- Loading branch information
1 parent
7956757
commit a774575
Showing
2 changed files
with
1,332 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
[ | ||
{ | ||
"name": "TestEnforceMVIndex", | ||
"cases": [ | ||
"select /*+ use_index(t, kj) */ * from t", | ||
"select /*+ use_index(t, kj) */ a from t", | ||
"select /*+ use_index(t, kj) */ * from t where a<10", | ||
"select /*+ use_index(t, kj) */ * from t where (1 member of (j))", | ||
"select /*+ use_index(t, kj) */ * from t where (1 member of (j)) and a=10", | ||
"select /*+ use_index(t, kj) */ * from t where (1 member of (j)) or a=10", | ||
"select /*+ use_index_merge(t, kj) */ * from t", | ||
"select /*+ use_index_merge(t, kj) */ a from t", | ||
"select /*+ use_index_merge(t, kj) */ * from t where a<10", | ||
"select /*+ use_index_merge(t, kj) */ * from t where (1 member of (j)) or a=10" | ||
] | ||
}, | ||
{ | ||
"name": "TestIndexMergeJSONMemberOf", | ||
"cases": [ | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where (1 member of (j0->'$.path0'))", | ||
"select /*+ use_index_merge(t, j0_1) */ * from t where (1 member of (j0->'$.path1')) and a<10", | ||
"select /*+ use_index_merge(t, j0_1) */ * from t where (1 member of (j0->'$.XXX')) and a<10", | ||
"select /*+ use_index_merge(t, j0_1) */ * from t where (1 member of (j0->'$.path1')) and (2 member of (j1)) and a<10", | ||
"select /*+ use_index(t, j0_0) */ * from t where (1 member of (j0->'$.path0'))", | ||
"select /*+ use_index(t, j0_1) */ * from t where (1 member of (j0->'$.path1')) and a<10", | ||
"select * from t use index(j0_0) where (1 member of (j0->'$.path0'))", | ||
"select * from t use index(j0_1) where (1 member of (j0->'$.path1')) and a<10", | ||
"select * from t force index(j0_0) where (1 member of (j0->'$.path0'))", | ||
"select * from t force index(j0_1) where (1 member of (j0->'$.path1')) and a<10", | ||
"select /*+ use_index_merge(t, j1) */ * from t where (1 member of (j0->'$.path1')) and (2 member of (j1)) and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_contains((j0->'$.path0'), '[1, 2, 3]')", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps((j0->'$.path0'), '[1, 2, 3]')", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps('[1, 2, 3]', (j0->'$.path0'))", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_contains((j0->'$.path0'), '[1, 2, 3]') and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps((j0->'$.path0'), '[1, 2, 3]') and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps('[1, 2, 3]', (j0->'$.path0')) and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_contains((j0->'$.path0'), '1')", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps((j0->'$.path0'), '1')", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps('1', (j0->'$.path0'))", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_contains((j0->'$.path0'), '1') and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps((j0->'$.path0'), '1') and a<10", | ||
"select /*+ use_index_merge(t, j0_0) */ * from t where json_overlaps('1', (j0->'$.path0')) and a<10", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where (\"a\" member of (j0->'$.path_string'))", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where (\"a\" member of (j0->'$.path_string')) and a<10", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where json_contains((j0->'$.path_string'), '[\"a\", \"b\", \"c\"]')", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where json_contains((j0->'$.path_string'), '[\"a\", \"b\", \"c\"]') and a<10", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where json_overlaps((j0->'$.path_string'), '[\"a\", \"b\", \"c\"]')", | ||
"select /*+ use_index_merge(t, j0_string) */ * from t where json_overlaps((j0->'$.path_string'), '[\"a\", \"b\", \"c\"]') and a<10", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where (\"2023-01-01\" member of (j0->'$.path_date'))", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where (\"2023-01-01\" member of (j0->'$.path_date')) and a<10", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where json_contains((j0->'$.path_date'), json_array(cast('2023-01-01' as date), cast('2023-01-02' as date), cast('2023-01-03' as date)))", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where json_contains((j0->'$.path_date'), json_array(cast('2023-01-01' as date), cast('2023-01-02' as date), cast('2023-01-03' as date))) and a<10", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where json_overlaps((j0->'$.path_date'), json_array(cast('2023-01-01' as date), cast('2023-01-02' as date), cast('2023-01-03' as date)))", | ||
"select /*+ use_index_merge(t, j0_date) */ * from t where json_overlaps((j0->'$.path_date'), json_array(cast('2023-01-01' as date), cast('2023-01-02' as date), cast('2023-01-03' as date))) and a<10" | ||
] | ||
}, | ||
{ | ||
"name": "TestCompositeMVIndex", | ||
"cases": [ | ||
"select /*+ use_index_merge(t, idx) */ * from t where a=1 and b=2 and (3 member of (j)) and c=4", | ||
"select /*+ use_index_merge(t, idx) */ * from t where a=1 and b=2 and (3 member of (j))", | ||
"select /*+ use_index_merge(t, idx) */ * from t where a=1 and b=2", | ||
"select /*+ use_index_merge(t, idx) */ * from t where a=1", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where a=1 and b=2 and ('3' member of (j->'$.str')) and c=4", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where a=1 and b=2 and ('3' member of (j->'$.str'))", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where a=1 and b=2", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where a=1", | ||
"select /*+ use_index(t, idx) */ * from t where a=1 and b=2 and (3 member of (j)) and c=4", | ||
"select * from t use index(idx) where a=1 and b=2 and (3 member of (j))", | ||
"select /*+ use_index(t, idx) */ * from t where a=1 and b=2", | ||
"select * from t use index(idx) where a=1", | ||
"select * from t force index(idx) where a=1 and b=2 and (3 member of (j))", | ||
"select * from t force index(idx) where a=1" | ||
] | ||
}, | ||
{ | ||
"name": "TestDNFOnMVIndex", | ||
"cases": [ | ||
"select /*+ use_index_merge(t, idx1) */ * from t where (1 member of (j)) or (2 member of (j))", | ||
"select /*+ use_index_merge(t, idx1) */ * from t where ((1 member of (j)) or (2 member of (j))) and (a > 10)", | ||
"select /*+ use_index_merge(t, idx1) */ * from t where (json_overlaps(j, '[1, 2]')) or (json_overlaps(j, '[3, 4]'))", | ||
"select /*+ use_index_merge(t, idx1) */ * from t where ((json_overlaps(j, '[1, 2]')) or (json_overlaps(j, '[3, 4]'))) and (a > 10)", | ||
"select /*+ use_index_merge(t, idx1) */ * from t where (json_contains(j, '[1, 2]')) or (json_contains(j, '[3, 4]'))", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where (a=1 and b=2 and (3 member of (j))) or (a=11 and b=12 and (13 member of (j)))", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where (a=1 and b=2 and (3 member of (j))) or (a=11 and b=12 and (13 member of (j)) and c=14)", | ||
"select /*+ use_index_merge(t, idx2) */ * from t where ((a=1 and b=2 and (3 member of (j))) or (a=11 and b=12 and (13 member of (j)))) and (c > 10)" | ||
] | ||
}, | ||
{ | ||
"name": "TestMVIndexSelection", | ||
"cases": [ | ||
"select (j->'$.int') from t where (1 member of (j->'$.int'))", | ||
"select * from t where (1 member of (j->'$.int'))", | ||
"select * from t where (1 member of (j->'$.int')) and a<10", | ||
"select (j->'$.int') from t where json_contains((j->'$.int'), '[1, 2, 3]')", | ||
"select * from t where json_contains((j->'$.int'), '[1, 2, 3]')", | ||
"select * from t where json_contains((j->'$.int'), '[1, 2, 3]') and a<10", | ||
"select (j->'$.int') from t where json_overlaps((j->'$.int'), '[1, 2, 3]')", | ||
"select * from t where json_overlaps((j->'$.int'), '[1, 2, 3]')", | ||
"select * from t where json_overlaps((j->'$.int'), '[1, 2, 3]') and a<10" | ||
] | ||
}, | ||
{ | ||
"name": "TestIndexMergePathGeneration", | ||
"cases": [ | ||
"select * from t", | ||
"select * from t where c < 1", | ||
"select * from t where c < 1 or f > 2", | ||
"select * from t where (c < 1 or f > 2) and (c > 5 or f < 7)", | ||
"select * from t where (c < 1 or f > 2) and (c > 5 or f < 7) and (c < 1 or g > 2)", | ||
"select * from t where (c < 1 or f > 2) and (c > 5 or f < 7) and (e < 1 or f > 2)" | ||
] | ||
}, | ||
{ | ||
"name": "TestHintForIntersectionIndexMerge", | ||
"cases": [ | ||
"set @@tidb_partition_prune_mode = 'dynamic'", | ||
"select * from vh", | ||
"select /*+ qb_name(v, v), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v1@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v1 where c < 30 and d in (2,5)", | ||
"select /*+ use_index_merge(t2, ia, ibc, id, ie) */ * from t2 where a > 10 and b = 20 and c < 35 and d < 45 and e = 100", | ||
"select /*+ use_index_merge(t3, ia, ibc, id, ie) */ * from t3 where a > 10 and b = 20 and c < 35 and d < 45 and e = 100", | ||
"select /*+ use_index_merge(t4, ia, ibc, id, ie) */ * from t4 where a > 10 and b = 20 and c < 35 and d in (1,3,8,9) and e = 100", | ||
"select /*+ use_index_merge(t5, is1, is2, is3, is4) */ * from t5 where s1 = 'Abc' and s2 > 'zzz' and s3 < 'B啊a' and s4 = 'CcC'", | ||
"select /*+ use_index_merge(t6, primary, is3, is4) */ * from t6 where s1 = 'Abc' and s2 > 'zzz' and s3 = 'A啊a' and s4 not like 'Cd_'", | ||
"select /*+ use_index_merge(t7, primary,ia,ib,ic,ie,iff,ig) */ * from t7 where a = 100 and b > 5 and c < 12.3 and d > 54.321 and e = '2022-11-22 17:00' and f > '2020-6-23 10:00' and g < 2025", | ||
"select /*+ use_index_merge(t8, primary,is2,is3,is4,is5) */ * from t8 where s1 like '啊A%' and s2 > 'abc' and s3 > 'cba' and s4 in ('aA', '??') and s5 = 'test,2'", | ||
"select (select /*+ use_index_merge(t1,ia,ibc,ic) */ a from t1 where t1.a > 10 and t1.b = 20 and t1.c = t2.a) from t2", | ||
"select (select /*+ use_index_merge(t1,ia,ibc,ic) */ a from t1 where t1.a > 10 and t1.b = 20 and t1.c > t2.a) from t2", | ||
"select (select /*+ use_index_merge(t1,ia,ibc,ic) */ a from t1 where t1.a > 10 and t1.b = 20 and t1.e > t2.a) from t2", | ||
"set @@tidb_partition_prune_mode = 'static'", | ||
"select * from vh", | ||
"select /*+ qb_name(v, v), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ qb_name(v, v@sel_1 .@sel_1), use_index_merge(@v t1, ia, ibc, id) */ * from v", | ||
"select /*+ use_index_merge(t2, ia, ibc, id, ie) */ * from t2 where a > 10 and b = 20 and c < 35 and d < 45 and e = 100", | ||
"select /*+ use_index_merge(t3, ia, ibc, id, ie) */ * from t3 where a > 10 and b = 20 and c < 35 and d < 45 and e = 100", | ||
"select /*+ use_index_merge(t4, ia, ibc, id, ie) */ * from t4 where a > 10 and b = 20 and c < 35 and d in (1,3,8,9) and e = 100" | ||
] | ||
} | ||
] |
Oops, something went wrong.