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: handle the expected row count for pushed-down selection in mpp #36195

Merged
merged 4 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
2 changes: 1 addition & 1 deletion planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
ColumnNames: ds.names,
}
ts.cost = cost
mppTask = ts.addPushedDownSelectionToMppTask(mppTask, ds.stats)
mppTask = ts.addPushedDownSelectionToMppTask(mppTask, ds.stats.ScaleByExpectCnt(prop.ExpectedCnt))
return mppTask, nil
}
copTask := &copTask{
Expand Down
28 changes: 28 additions & 0 deletions planner/core/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6989,3 +6989,31 @@ func TestIssue25813(t *testing.T) {
" └─TableReader(Probe) 10000.00 root data:TableFullScan",
" └─TableFullScan 10000.00 cop[tikv] table:t1 keep order:false, stats:pseudo"))
}

func TestIssue36194(t *testing.T) {
store, dom, clean := testkit.CreateMockStoreAndDomain(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int)")
// create virtual tiflash replica.
is := dom.InfoSchema()
db, exists := is.SchemaByName(model.NewCIStr("test"))
require.True(t, exists)
for _, tblInfo := range db.Tables {
if tblInfo.Name.L == "t" {
tblInfo.TiFlashReplica = &model.TiFlashReplicaInfo{
Count: 1,
Available: true,
}
}
}
tk.MustQuery("explain format = 'brief' select * from t where a + 1 > 20 limit 100;;").Check(testkit.Rows(
"Limit 100.00 root offset:0, count:100",
"└─TableReader 100.00 root data:ExchangeSender",
" └─ExchangeSender 100.00 mpp[tiflash] ExchangeType: PassThrough",
" └─Limit 100.00 mpp[tiflash] offset:0, count:100",
" └─Selection 100.00 mpp[tiflash] gt(plus(test.t.a, 1), 20)",
" └─TableFullScan 125.00 mpp[tiflash] table:t keep order:false, stats:pseudo"))
}
6 changes: 3 additions & 3 deletions planner/core/testdata/integration_suite_out.json
Original file line number Diff line number Diff line change
Expand Up @@ -5952,7 +5952,7 @@
" │ └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: Broadcast",
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo",
" └─Selection(Probe) 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" └─Selection(Probe) 0.80 mpp[tiflash] not(isnull(test.t.id))",
" └─TableFullScan 0.80 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
]
},
Expand All @@ -5968,7 +5968,7 @@
" │ └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: Broadcast",
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo",
" └─Selection(Probe) 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" └─Selection(Probe) 0.80 mpp[tiflash] not(isnull(test.t.id))",
" └─TableFullScan 0.80 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
]
},
Expand All @@ -5985,7 +5985,7 @@
" │ └─ExchangeSender 9990.00 mpp[tiflash] ExchangeType: Broadcast",
" │ └─Selection 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" │ └─TableFullScan 10000.00 mpp[tiflash] table:t keep order:false, stats:pseudo",
" └─Selection(Probe) 9990.00 mpp[tiflash] not(isnull(test.t.id))",
" └─Selection(Probe) 16.00 mpp[tiflash] not(isnull(test.t.id))",
" └─TableFullScan 16.02 mpp[tiflash] table:t1 keep order:false, stats:pseudo"
]
}
Expand Down