Skip to content

Commit

Permalink
Revert "support specify a partition"
Browse files Browse the repository at this point in the history
This reverts commit d2b4cb9.
  • Loading branch information
Defined2014 committed Jul 12, 2024
1 parent d2b4cb9 commit 7723ddc
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 38 deletions.
11 changes: 3 additions & 8 deletions pkg/planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,6 @@ func (ds *DataSource) FindBestTask(prop *property.PhysicalProperty, planCounter
if canConvertPointGet && ds.table.Meta().GetPartitionInfo() != nil {
// partition table with dynamic prune not support batchPointGet
// Due to sorting?
// Please make sure handle `where _tidb_rowid in (xx, xx)` correctly when delete this if statements.
if canConvertPointGet && len(path.Ranges) > 1 && ds.SCtx().GetSessionVars().StmtCtx.UseDynamicPartitionPrune() {
canConvertPointGet = false
}
Expand All @@ -1419,8 +1418,8 @@ func (ds *DataSource) FindBestTask(prop *property.PhysicalProperty, planCounter
canConvertPointGet = false
}
}
// Partition table can't use `_tidb_rowid` to generate PointGet Plan unless one partition is explicitly specified.
if canConvertPointGet && path.IsIntHandlePath && ds.HandleCols != nil && ds.HandleCols.GetCol(0).ID == model.ExtraHandleID && len(ds.PartitionNames) != 1 {
// Partition table can't use `_tidb_rowid` to generate PointGet Plan.
if canConvertPointGet && path.IsIntHandlePath && ds.HandleCols != nil && ds.HandleCols.GetCol(0).ID == model.ExtraHandleID {
canConvertPointGet = false
}
if canConvertPointGet {
Expand Down Expand Up @@ -2628,11 +2627,7 @@ func (ds *DataSource) convertToPointGet(prop *property.PhysicalProperty, candida
found := false
for i := range ds.Columns {
if ds.Columns[i].ID == ds.HandleCols.GetCol(0).ID {
if ds.HandleCols.GetCol(0).ID == model.ExtraHandleID {
pointGetPlan.HandleColOffset = -1
} else {
pointGetPlan.HandleColOffset = ds.Columns[i].Offset
}
pointGetPlan.HandleColOffset = ds.Columns[i].Offset
found = true
break
}
Expand Down
10 changes: 0 additions & 10 deletions pkg/planner/core/point_get_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,16 +339,6 @@ func (p *PointGetPlan) PrunePartitions(sctx sessionctx.Context) bool {
// reading for the Global Index / table id
return false
}
if p.IndexInfo == nil && p.HandleColOffset == -1 && len(p.PartitionNames) == 1 {
// _tidb_rowid + specify a partition
for i, def := range pi.Definitions {
if def.Name.L == p.PartitionNames[0].L {
p.PartitionIdx = &i
break
}
}
return false
}
// If tryPointGetPlan did generate the plan,
// then PartitionIdx is not set and needs to be set here!
// There are two ways to get here from static mode partition pruning:
Expand Down
15 changes: 0 additions & 15 deletions tests/integrationtest/r/planner/core/integration_partition.result
Original file line number Diff line number Diff line change
Expand Up @@ -1304,18 +1304,3 @@ TableReader_6 2.00 root partition:all data:TableRangeScan_5
select *,_tidb_rowid from t where _tidb_rowid=1;
id _tidb_rowid
0 1
explain select *,_tidb_rowid from t partition(p0) where _tidb_rowid=1;
id estRows task access object operator info
Point_Get_5 1.00 root table:t, partition:p0 handle:1
select *,_tidb_rowid from t partition(p0) where _tidb_rowid=1;
id _tidb_rowid
0 1
explain select *,_tidb_rowid from t partition(p1) where _tidb_rowid=1;
id estRows task access object operator info
Point_Get_5 1.00 root table:t, partition:p1 handle:1
select *,_tidb_rowid from t partition(p1) where _tidb_rowid=1;
id _tidb_rowid
explain select *,_tidb_rowid from t partition(p0,p1) where _tidb_rowid=1;
id estRows task access object operator info
TableReader_6 2.00 root partition:p0,p1 data:TableRangeScan_5
└─TableRangeScan_5 2.00 cop[tikv] table:t range:[1,1], keep order:false
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,3 @@ insert into t values(0),(0);
analyze table t;
explain select *,_tidb_rowid from t where _tidb_rowid=1;
select *,_tidb_rowid from t where _tidb_rowid=1;
explain select *,_tidb_rowid from t partition(p0) where _tidb_rowid=1;
select *,_tidb_rowid from t partition(p0) where _tidb_rowid=1;
explain select *,_tidb_rowid from t partition(p1) where _tidb_rowid=1;
select *,_tidb_rowid from t partition(p1) where _tidb_rowid=1;
explain select *,_tidb_rowid from t partition(p0,p1) where _tidb_rowid=1;

0 comments on commit 7723ddc

Please sign in to comment.