Skip to content

Commit

Permalink
config: Change tidb_opt_projection_push_down default value to true (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yibin87 authored Jul 8, 2024
1 parent 08147e7 commit 0f81cea
Show file tree
Hide file tree
Showing 30 changed files with 468 additions and 466 deletions.
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ var defaultConf = Config{
TxnEntrySizeLimit: DefTxnEntrySizeLimit,
TxnTotalSizeLimit: DefTxnTotalSizeLimit,
DistinctAggPushDown: false,
ProjectionPushDown: false,
ProjectionPushDown: true,
CommitterConcurrency: defTiKVCfg.CommitterConcurrency,
MaxTxnTTL: defTiKVCfg.MaxTxnTTL, // 1hour
GOGC: 100,
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/distsql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ func TestAdaptiveClosestRead(t *testing.T) {
// the avg row size is more accurate in check_rpc mode when unistre is used.
// See: https://github.com/pingcap/tidb/issues/31744#issuecomment-1016309883
tk.MustExec("set @@tidb_enable_chunk_rpc = '1'")
tk.MustExec("set @@tidb_opt_projection_push_down = '0'")

readCounter := func(counter prometheus.Counter) float64 {
var metric dto.Metric
Expand Down
1 change: 1 addition & 0 deletions pkg/executor/explainfor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ func TestIssue28259(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec(`set tidb_enable_prepared_plan_cache=1`)
tk.MustExec(`set tidb_opt_projection_push_down=0`)

// test for indexRange
tk.MustExec("use test")
Expand Down
24 changes: 12 additions & 12 deletions pkg/executor/testdata/prepare_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
}
],
"Plan": [
"Projection_4 10.00 root test.t1.a",
"└─IndexReader_6 10.00 root index:IndexRangeScan_5",
" └─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b(b, a) range:[3,3], keep order:false, stats:pseudo"
"IndexReader_9 10.00 root index:Projection_5",
"└─Projection_5 10.00 cop[tikv] test.t1.a",
" └─IndexRangeScan_8 10.00 cop[tikv] table:t1, index:b(b, a) range:[3,3], keep order:false, stats:pseudo"
],
"LastPlanUseCache": "0",
"Result": [
Expand All @@ -100,9 +100,9 @@
}
],
"Plan": [
"Projection_4 10.00 root test.t1.a",
"└─IndexReader_6 10.00 root index:IndexRangeScan_5",
" └─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b(b, a) range:[2,2], keep order:false, stats:pseudo"
"IndexReader_9 10.00 root index:Projection_5",
"└─Projection_5 10.00 cop[tikv] test.t1.a",
" └─IndexRangeScan_8 10.00 cop[tikv] table:t1, index:b(b, a) range:[2,2], keep order:false, stats:pseudo"
],
"LastPlanUseCache": "1",
"Result": [
Expand All @@ -118,9 +118,9 @@
}
],
"Plan": [
"Projection_4 10.00 root test.t1.a",
"└─IndexReader_6 10.00 root index:IndexRangeScan_5",
" └─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b(b, a) range:[-200,-200], keep order:false, stats:pseudo"
"IndexReader_9 10.00 root index:Projection_5",
"└─Projection_5 10.00 cop[tikv] test.t1.a",
" └─IndexRangeScan_8 10.00 cop[tikv] table:t1, index:b(b, a) range:[-200,-200], keep order:false, stats:pseudo"
],
"LastPlanUseCache": "1",
"Result": null
Expand All @@ -134,9 +134,9 @@
}
],
"Plan": [
"Projection_4 10.00 root test.t1.a",
"└─IndexReader_6 10.00 root index:IndexRangeScan_5",
" └─IndexRangeScan_5 10.00 cop[tikv] table:t1, index:b(b, a) range:[0,0], keep order:false, stats:pseudo"
"IndexReader_9 10.00 root index:Projection_5",
"└─Projection_5 10.00 cop[tikv] test.t1.a",
" └─IndexRangeScan_8 10.00 cop[tikv] table:t1, index:b(b, a) range:[0,0], keep order:false, stats:pseudo"
],
"LastPlanUseCache": "0",
"Result": null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ func TestQuickBinding(t *testing.T) {
tk := s.newTestKitWithRoot(t)
require.NoError(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil, nil))

tk.MustExec("set tidb_opt_projection_push_down = 0")
tk.MustExec("use test")
tk.MustExec(`create table t1 (pk int, a int, b int, c int, primary key(pk), key k_a(a), key k_bc(b, c))`)
tk.MustExec(`create table t2 (a int, b int, c int, key k_a(a), key k_bc(b, c))`) // no primary key
Expand Down
4 changes: 2 additions & 2 deletions pkg/planner/cardinality/testdata/cardinality_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -4177,8 +4177,8 @@
{
"Query": "explain format = 'brief' select a, b from t where a = 1 and b = 1 and c = 1",
"Result": [
"Projection 16.00 root test.t.a, test.t.b",
"└─IndexReader 16.00 root index:IndexRangeScan",
"IndexReader 16.00 root index:Projection",
"└─Projection 16.00 cop[tikv] test.t.a, test.t.b",
" └─IndexRangeScan 16.00 cop[tikv] table:t, index:iabc(a, b, c) range:[1 1 1,1 1 1], keep order:false"
]
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/planner/core/casetest/dag/testdata/plan_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
},
{
"SQL": "select f from t where a > 1",
"Best": "TableReader(Table(t))->Projection"
"Best": "TableReader(Table(t)->Projection)"
},
{
"SQL": "select f from t where a > 1 limit 10",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@
{
"SQL": "explain select /*+ READ_FROM_STORAGE(TIFLASH[s]) */ a from s where a = 10 and b is null; -- index path huristic rule will prune tiflash path",
"Plan": [
"TableReader_15 0.10 root MppVersion: 2, data:ExchangeSender_14",
"└─ExchangeSender_14 0.10 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection_13 0.10 mpp[tiflash] test.s.a",
" └─Selection_10 0.10 mpp[tiflash] isnull(test.s.b)",
" └─TableFullScan_9 10.00 mpp[tiflash] table:s pushed down filter:eq(test.s.a, 10), keep order:false, stats:pseudo"
"TableReader_17 0.10 root MppVersion: 2, data:ExchangeSender_16",
"└─ExchangeSender_16 0.10 mpp[tiflash] ExchangeType: PassThrough",
" └─Projection_14 0.10 mpp[tiflash] test.s.a",
" └─Selection_11 0.10 mpp[tiflash] isnull(test.s.b)",
" └─TableFullScan_10 10.00 mpp[tiflash] table:s pushed down filter:eq(test.s.a, 10), keep order:false, stats:pseudo"
],
"Warn": null
},
Expand Down Expand Up @@ -361,8 +361,8 @@
"SQL": "EXPLAIN format = 'brief' SELECT count(a) from t where c=1; -- 11. type not supported",
"Plan": [
"StreamAgg 1.00 root funcs:count(test.t.a)->Column#6",
"└─Projection 10.00 root test.t.a",
" └─TableReader 10.00 root data:Selection",
"└─TableReader 10.00 root data:Projection",
" └─Projection 10.00 cop[tikv] test.t.a",
" └─Selection 10.00 cop[tikv] eq(test.t.c, 1)",
" └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo"
],
Expand All @@ -377,8 +377,8 @@
"SQL": "EXPLAIN format = 'brief' SELECT count(a) from t where d=1; -- 11.1. type not supported",
"Plan": [
"StreamAgg 1.00 root funcs:count(test.t.a)->Column#6",
"└─Projection 10.00 root test.t.a",
" └─TableReader 10.00 root data:Selection",
"└─TableReader 10.00 root data:Projection",
" └─Projection 10.00 cop[tikv] test.t.a",
" └─Selection 10.00 cop[tikv] eq(test.t.d, 1)",
" └─TableFullScan 10000.00 cop[tikv] table:t keep order:false, stats:pseudo"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@
{
"Depth": 1,
"Label": 0,
"IsRoot": true,
"StoreType": 2,
"IsRoot": false,
"StoreType": 0,
"ReqType": 0,
"IsPhysicalPlan": true,
"TextTreeIndent": "",
Expand Down Expand Up @@ -156,8 +156,8 @@
{
"Depth": 1,
"Label": 0,
"IsRoot": true,
"StoreType": 2,
"IsRoot": false,
"StoreType": 0,
"ReqType": 0,
"IsPhysicalPlan": true,
"TextTreeIndent": "",
Expand Down
44 changes: 22 additions & 22 deletions pkg/planner/core/casetest/index/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
{
"SQL": "select b from t3 where a = 1 and b is not null",
"Plan": [
"Projection 10.00 root test.t3.b",
"└─TableReader 10.00 root data:TableRangeScan",
"TableReader 10.00 root data:Projection",
"└─Projection 10.00 cop[tikv] test.t3.b",
" └─TableRangeScan 10.00 cop[tikv] table:t3 range:[1,1], keep order:false, stats:pseudo"
],
"Result": [
Expand All @@ -207,53 +207,53 @@
{
"SQL": "select k1 from t1 where (k1,k2) > (1,2)",
"Plan": [
"Projection 3366.67 root test.t1.k1",
"└─IndexReader 3366.67 root index:IndexRangeScan",
"IndexReader 3366.67 root index:Projection",
"└─Projection 3366.67 cop[tikv] test.t1.k1",
" └─IndexRangeScan 3366.67 cop[tikv] table:t1, index:pk1(k1, k2) range:(1 2,1 +inf], (1,+inf], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1,k2) >= (1,2)",
"Plan": [
"Projection 3366.67 root test.t1.k1",
"└─IndexReader 3366.67 root index:IndexRangeScan",
"IndexReader 3366.67 root index:Projection",
"└─Projection 3366.67 cop[tikv] test.t1.k1",
" └─IndexRangeScan 3366.67 cop[tikv] table:t1, index:pk1(k1, k2) range:[1 2,1 +inf], (1,+inf], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1,k2) < (1,2)",
"Plan": [
"Projection 3356.57 root test.t1.k1",
"└─IndexReader 3356.57 root index:IndexRangeScan",
"IndexReader 3356.57 root index:Projection",
"└─Projection 3356.57 cop[tikv] test.t1.k1",
" └─IndexRangeScan 3356.57 cop[tikv] table:t1, index:pk1(k1, k2) range:[-inf,1), [1 -inf,1 2), keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1, k2) <= (1,2)",
"Plan": [
"Projection 3356.57 root test.t1.k1",
"└─IndexReader 3356.57 root index:IndexRangeScan",
"IndexReader 3356.57 root index:Projection",
"└─Projection 3356.57 cop[tikv] test.t1.k1",
" └─IndexRangeScan 3356.57 cop[tikv] table:t1, index:pk1(k1, k2) range:[-inf,1), [1 -inf,1 2], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1,k2) = (1,2)",
"Plan": [
"Projection 0.10 root test.t1.k1",
"└─IndexReader 0.10 root index:IndexRangeScan",
"IndexReader 0.10 root index:Projection",
"└─Projection 0.10 cop[tikv] test.t1.k1",
" └─IndexRangeScan 0.10 cop[tikv] table:t1, index:pk1(k1, k2) range:[1 2,1 2], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1, k2) != (1,2); -- could not match range scan",
"Plan": [
"Projection 8882.21 root test.t1.k1",
"└─IndexReader 8882.21 root index:Selection",
"IndexReader 8882.21 root index:Projection",
"└─Projection 8882.21 cop[tikv] test.t1.k1",
" └─Selection 8882.21 cop[tikv] or(ne(test.t1.k1, 1), ne(test.t1.k2, 2))",
" └─IndexFullScan 10000.00 cop[tikv] table:t1, index:pk1(k1, k2) keep order:false, stats:pseudo"
],
Expand All @@ -270,35 +270,35 @@
{
"SQL": "select k1 from t1 where (k1, k2) in ((1,2), (3,4))",
"Plan": [
"Projection 0.20 root test.t1.k1",
"└─IndexReader 0.20 root index:IndexRangeScan",
"IndexReader 0.20 root index:Projection",
"└─Projection 0.20 cop[tikv] test.t1.k1",
" └─IndexRangeScan 0.20 cop[tikv] table:t1, index:pk1(k1, k2) range:[1 2,1 2], [3 4,3 4], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1, k2) > (1,2) and (k1, k2) < (4,5)",
"Plan": [
"Projection 316.57 root test.t1.k1",
"└─IndexReader 316.57 root index:IndexRangeScan",
"IndexReader 316.57 root index:Projection",
"└─Projection 316.57 cop[tikv] test.t1.k1",
" └─IndexRangeScan 316.57 cop[tikv] table:t1, index:pk1(k1, k2) range:(1 2,1 +inf], (1,4), [4 -inf,4 5), keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k1, k2) >= (1,2) and (k1, k2) <= (4,5)",
"Plan": [
"Projection 316.57 root test.t1.k1",
"└─IndexReader 316.57 root index:IndexRangeScan",
"IndexReader 316.57 root index:Projection",
"└─Projection 316.57 cop[tikv] test.t1.k1",
" └─IndexRangeScan 316.57 cop[tikv] table:t1, index:pk1(k1, k2) range:[1 2,1 +inf], (1,4), [4 -inf,4 5], keep order:false, stats:pseudo"
],
"Result": null
},
{
"SQL": "select k1 from t1 where (k2, k3) > (1,2); -- could not match range scan ",
"Plan": [
"Projection 3335.56 root test.t1.k1",
"└─TableReader 3335.56 root data:Selection",
"TableReader 3335.56 root data:Projection",
"└─Projection 3335.56 cop[tikv] test.t1.k1",
" └─Selection 3335.56 cop[tikv] or(gt(test.t1.k2, 1), and(eq(test.t1.k2, 1), gt(test.t1.k3, 2)))",
" └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"
],
Expand Down
Loading

0 comments on commit 0f81cea

Please sign in to comment.