Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Mar 12, 2024
1 parent 85fa14f commit dbf2229
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 85 deletions.
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ go_test(
],
data = glob(["testdata/**"]),
flaky = True,
shard_count = 20,
shard_count = 19,
deps = [
"//pkg/domain",
"//pkg/parser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,14 +188,16 @@
{
"SQL": "explain select /*+ read_from_storage(tiflash[t3]) */ * from t3 where sala='a' and id =1; -- once hinted, walk with tiflash range scan",
"Plan": [
"Point_Get_1 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) "
"TableReader_11 0.01 root partition:p1 MppVersion: 2, data:ExchangeSender_10",
"└─ExchangeSender_10 0.01 mpp[tiflash] ExchangeType: PassThrough",
" └─TableRangeScan_9 1.00 mpp[tiflash] table:t3 range:[1 \"a\",1 \"a\"], keep order:false, stats:pseudo, PartitionTableScan:true"
],
"Warn": null
},
{
"SQL": "explain select * from t3 where sala='a' and id =1; -- once not hinted, walk with tikv point get",
"Plan": [
"Point_Get_1 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) "
"Point_Get_5 1.00 root table:t3, partition:p1, clustered index:PRIMARY(id, sala) "
],
"Warn": null
}
Expand Down
44 changes: 0 additions & 44 deletions pkg/planner/core/casetest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,47 +385,3 @@ func TestFixControl45132(t *testing.T) {
tk.MustExec(`set @@tidb_opt_fix_control = "45132:0"`)
tk.MustHavePlan(`select * from t where a=2`, `TableFullScan`)
}

func TestInvisibleIndex(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)

tk.MustExec("use test")
tk.MustExec("drop table if exists t")

// Optimizer cannot see invisible indexes.
tk.MustExec("create table t(a int, b int, unique index i_a (a) invisible, unique index i_b(b))")
tk.MustExec("insert into t values (1,2)")

// For issue 26217, can't use invisible index after admin check table.
tk.MustExec("admin check table t")

// Optimizer cannot use invisible indexes.
tk.MustQuery("select a from t order by a").Check(testkit.Rows("1"))
require.False(t, tk.MustUseIndex("select a from t order by a", "i_a"))
tk.MustQuery("select a from t where a > 0").Check(testkit.Rows("1"))
require.False(t, tk.MustUseIndex("select a from t where a > 1", "i_a"))

// If use invisible indexes in index hint and sql hint, throw an error.
errStr := "[planner:1176]Key 'i_a' doesn't exist in table 't'"
tk.MustGetErrMsg("select * from t use index(i_a)", errStr)
tk.MustGetErrMsg("select * from t force index(i_a)", errStr)
tk.MustGetErrMsg("select * from t ignore index(i_a)", errStr)
tk.MustQuery("select /*+ USE_INDEX(t, i_a) */ * from t")
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1)
require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr)
tk.MustQuery("select /*+ IGNORE_INDEX(t, i_a), USE_INDEX(t, i_b) */ a from t order by a")
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1)
require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr)
tk.MustQuery("select /*+ FORCE_INDEX(t, i_a), USE_INDEX(t, i_b) */ a from t order by a")
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1)
require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, errStr)
// For issue 15519
inapplicableErrStr := "[planner:1815]force_index(test.aaa) is inapplicable, check whether the table(test.aaa) exists"
tk.MustQuery("select /*+ FORCE_INDEX(aaa) */ * from t")
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 1)
require.EqualError(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings()[0].Err, inapplicableErrStr)

tk.MustExec("admin check table t")
tk.MustExec("admin check index t i_a")
}
Original file line number Diff line number Diff line change
Expand Up @@ -680,8 +680,8 @@
],
"StaticPlan": [
"PartitionUnion 2.00 root ",
"├─Batch_Point_Get 1.00 root table:t, partition:p1 handle:[1], keep order:false, desc:false",
"└─Batch_Point_Get 1.00 root table:t, partition:P2 handle:[2], keep order:false, desc:false"
"├─Batch_Point_Get 1.00 root table:t handle:[1 2], keep order:false, desc:false",
"└─Batch_Point_Get 1.00 root table:t handle:[1 2], keep order:false, desc:false"
]
},
{
Expand Down Expand Up @@ -887,7 +887,7 @@
"└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false"
"Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -901,7 +901,7 @@
"└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:true, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:true, desc:false"
"Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:true, desc:false"
],
"Result": [
"1 1",
Expand All @@ -915,7 +915,7 @@
"└─IndexRangeScan 2.00 cop[tikv] table:thash1, index:PRIMARY(a, b) range:[1 1,1 1], [2 1,2 1], keep order:true, desc, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:true, desc:true"
"Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:true, desc:true"
],
"Result": [
"2 1",
Expand All @@ -930,8 +930,8 @@
],
"StaticPlan": [
"PartitionUnion 4.00 root ",
"├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false"
"├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -947,8 +947,8 @@
"StaticPlan": [
"Sort 4.00 root test.thash1.b",
"└─PartitionUnion 4.00 root ",
" ├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false"
" ├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -964,8 +964,8 @@
"StaticPlan": [
"Sort 4.00 root test.thash1.b:desc",
"└─PartitionUnion 4.00 root ",
" ├─Batch_Point_Get 2.00 root table:thash1, partition:p0, index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash1, partition:p1, index:PRIMARY(a, b) keep order:false, desc:false"
" ├─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash1, index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 2",
Expand Down Expand Up @@ -1181,7 +1181,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false"
"Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -1195,7 +1195,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:true, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:true, desc:false"
"Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:true, desc:false"
],
"Result": [
"1 1",
Expand All @@ -1210,7 +1210,7 @@
" └─TableRangeScan 2.00 cop[tikv] table:thash2 range:[1 1,1 1], [2 1,2 1], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:true, desc:true"
"Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:true, desc:true"
],
"Result": [
"2 1",
Expand All @@ -1225,8 +1225,8 @@
],
"StaticPlan": [
"PartitionUnion 0.04 root ",
"├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false"
"├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -1242,8 +1242,8 @@
"StaticPlan": [
"Sort 0.04 root test.thash2.b",
"└─PartitionUnion 0.04 root ",
" ├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false"
" ├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 1",
Expand All @@ -1260,8 +1260,8 @@
"StaticPlan": [
"Sort 0.04 root test.thash2.b:desc",
"└─PartitionUnion 0.04 root ",
" ├─Batch_Point_Get 2.00 root table:thash2, partition:p0, clustered index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash2, partition:p1, clustered index:PRIMARY(a, b) keep order:false, desc:false"
" ├─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false",
" └─Batch_Point_Get 2.00 root table:thash2, clustered index:PRIMARY(a, b) keep order:false, desc:false"
],
"Result": [
"1 2",
Expand Down Expand Up @@ -1484,8 +1484,8 @@
],
"StaticPlan": [
"PartitionUnion 4.00 root ",
"├─Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[2], keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1], keep order:false, desc:false"
"├─Batch_Point_Get 2.00 root table:thash3 handle:[1 2], keep order:false, desc:false",
"└─Batch_Point_Get 2.00 root table:thash3 handle:[1 2], keep order:false, desc:false"
],
"Result": [
"1 0",
Expand All @@ -1499,7 +1499,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:false, desc:false"
"Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:false, desc:false"
],
"Result": [
"1 0",
Expand All @@ -1513,7 +1513,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:true, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:true, desc:false"
"Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:true, desc:false"
],
"Result": [
"1 0",
Expand All @@ -1527,7 +1527,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [3,3], keep order:true, desc, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash3, partition:p1 handle:[1 3], keep order:true, desc:true"
"Batch_Point_Get 2.00 root table:thash3 handle:[1 3], keep order:true, desc:true"
],
"Result": [
"3 0",
Expand All @@ -1541,7 +1541,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[1,1], [4,4], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[4], keep order:false, desc:false"
"Batch_Point_Get 2.00 root table:thash3 handle:[1 4], keep order:false, desc:false"
],
"Result": [
"4 0"
Expand All @@ -1565,7 +1565,7 @@
"└─TableRangeScan 2.00 cop[tikv] table:thash3 range:[2,2], [4,4], keep order:false, stats:pseudo"
],
"StaticPlan": [
"Batch_Point_Get 2.00 root table:thash3, partition:p0 handle:[2 4], keep order:false, desc:false"
"Batch_Point_Get 2.00 root table:thash3 handle:[2 4], keep order:false, desc:false"
],
"Result": [
"2 0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,12 @@
"└─Shuffle_27 10000.00 root execution info: concurrency:5, data sources:[Window_14]",
" └─Window_12 10000.00 root sum(cast(Column#7, decimal(20,0) BINARY))->Column#9 over(partition by test.employee.deptid)",
" └─Sort_26 10000.00 root test.employee.deptid",
" └─ShuffleReceiver_28 10000.00 root ",
" └─Window_14 10000.00 root row_number()->Column#7 over(order by Column#6 rows between current row and current row)",
" └─Sort_25 10000.00 root Column#6",
" └─Projection_19 10000.00 root test.employee.empid, test.employee.deptid, test.employee.salary, md5(cast(test.employee.deptid, var_string(20)))->Column#6",
" └─TableReader_24 10000.00 root MppVersion: 2, data:ExchangeSender_23",
" └─ExchangeSender_23 10000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─TableFullScan_22 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
" └─Window_14 10000.00 root row_number()->Column#7 over(order by Column#6 rows between current row and current row)",
" └─Sort_25 10000.00 root Column#6",
" └─Projection_19 10000.00 root test.employee.empid, test.employee.deptid, test.employee.salary, md5(cast(test.employee.deptid, var_string(20)))->Column#6",
" └─TableReader_24 10000.00 root MppVersion: 2, data:ExchangeSender_23",
" └─ExchangeSender_23 10000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─TableFullScan_22 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because window function `sum` or its arguments are not supported now.",
Expand Down Expand Up @@ -325,10 +324,9 @@
"Shuffle_15 10000.00 root execution info: concurrency:5, data sources:[TableReader_13]",
"└─Window_8 10000.00 root sum(test.employee.salary)->Column#6 over(partition by test.employee.empid order by test.employee.salary range between 1 preceding and 1 following)",
" └─Sort_14 10000.00 root test.employee.empid, test.employee.salary",
" └─ShuffleReceiver_16 10000.00 root ",
" └─TableReader_13 10000.00 root MppVersion: 2, data:ExchangeSender_12",
" └─ExchangeSender_12 10000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─TableFullScan_11 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
" └─TableReader_13 10000.00 root MppVersion: 2, data:ExchangeSender_12",
" └─ExchangeSender_12 10000.00 mpp[tiflash] ExchangeType: PassThrough",
" └─TableFullScan_11 10000.00 mpp[tiflash] table:employee keep order:false, stats:pseudo"
],
"Warn": [
"MPP mode may be blocked because window function `sum` or its arguments are not supported now.",
Expand Down

0 comments on commit dbf2229

Please sign in to comment.