Skip to content

Commit

Permalink
planner: do not convert filter to range for table scan with tiflash (p…
Browse files Browse the repository at this point in the history
  • Loading branch information
lzmhhh123 committed Jan 17, 2020
1 parent 5e430b8 commit cfdff94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
10 changes: 10 additions & 0 deletions cmd/explaintest/r/access_tiflash.result
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,13 @@ StreamAgg_16 1.00 root funcs:sum(Column#7)
└─TableReader_17 1.00 root data:StreamAgg_8
└─StreamAgg_8 1.00 cop[tiflash] funcs:sum(isnull(Column#1))
└─TableScan_15 10000.00 cop[tiflash] table:t, range:[-inf,+inf], keep order:false, stats:pseudo
create table tt(a int, b int, primary key(a));
desc select * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55);
id count task operator info
TableReader_6 44.00 root data:TableScan_5
└─TableScan_5 44.00 cop[tikv] table:tt, range:(1,20), [30,55), keep order:false, stats:pseudo
desc select /*+ read_from_storage(tiflash[tt]) */ * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55);
id count task operator info
TableReader_7 44.00 root data:Selection_6
└─Selection_6 44.00 cop[tiflash] or(and(gt(Column#1, 1), lt(Column#1, 20)), and(ge(Column#1, 30), lt(Column#1, 55)))
└─TableScan_5 44.00 cop[tiflash] table:tt, range:[-inf,+inf], keep order:false, stats:pseudo
7 changes: 6 additions & 1 deletion cmd/explaintest/t/access_tiflash.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ desc select /*+ read_from_storage(tiflash[t]) */ sum(a) from t;

desc select /*+ read_from_storage(tiflash[t]) */ sum(a+1) from t;

desc select /*+ read_from_storage(tiflash[t]) */ sum(isnull(a)) from t;
desc select /*+ read_from_storage(tiflash[t]) */ sum(isnull(a)) from t;

create table tt(a int, b int, primary key(a));

desc select * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55);
desc select /*+ read_from_storage(tiflash[tt]) */ * from tt where (tt.a > 1 and tt.a < 20) or (tt.a >= 30 and tt.a < 55);
3 changes: 3 additions & 0 deletions planner/core/find_best_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,9 @@ func (ds *DataSource) convertToTableScan(prop *property.PhysicalProperty, candid
}.Init(ds.ctx)
if ds.preferStoreType&preferTiFlash != 0 {
ts.StoreType = kv.TiFlash
ts.filterCondition = append(ts.filterCondition, ts.AccessCondition...)
ts.AccessCondition = nil
ts.Ranges = ranger.FullNotNullRange()
} else {
ts.StoreType = kv.TiKV
}
Expand Down

0 comments on commit cfdff94

Please sign in to comment.