File tree 3 files changed +6
-26
lines changed
src/frontend/src/optimizer 3 files changed +6
-26
lines changed Original file line number Diff line number Diff line change @@ -407,20 +407,10 @@ impl LogicalJoin {
407
407
result_plan = Some ( lookup_join) ;
408
408
}
409
409
410
- let required_col_idx = logical_scan. required_col_idx ( ) ;
411
410
let indexes = logical_scan. indexes ( ) ;
412
411
for index in indexes {
413
- let p2s_mapping = index. primary_to_secondary_mapping ( ) ;
414
- if required_col_idx. iter ( ) . all ( |x| p2s_mapping. contains_key ( x) ) {
415
- // Covering index selection
416
- let index_scan: PlanRef = logical_scan
417
- . to_index_scan (
418
- & index. name ,
419
- index. index_table . table_desc ( ) . into ( ) ,
420
- p2s_mapping,
421
- )
422
- . into ( ) ;
423
-
412
+ if let Some ( index_scan) = logical_scan. to_index_scan_if_index_covered ( index) {
413
+ let index_scan: PlanRef = index_scan. into ( ) ;
424
414
let that = self . clone_with_left_right ( self . left ( ) , index_scan. clone ( ) ) ;
425
415
let new_logical_join = logical_join. clone_with_left_right (
426
416
logical_join. left ( ) ,
Original file line number Diff line number Diff line change @@ -664,12 +664,11 @@ impl ToBatch for LogicalScan {
664
664
if let Some ( applied) = index_selection_rule. apply ( new. clone ( ) . into ( ) ) {
665
665
if let Some ( scan) = applied. as_logical_scan ( ) {
666
666
// covering index
667
- return required_order. enforce_if_not_satisfies ( scan. to_batch ( ) . unwrap ( ) ) ;
667
+ return required_order. enforce_if_not_satisfies ( scan. to_batch ( ) ? ) ;
668
668
} else if let Some ( join) = applied. as_logical_join ( ) {
669
669
// index lookup join
670
- return required_order. enforce_if_not_satisfies (
671
- join. index_lookup_join_to_batch_lookup_join ( ) . unwrap ( ) ,
672
- ) ;
670
+ return required_order
671
+ . enforce_if_not_satisfies ( join. index_lookup_join_to_batch_lookup_join ( ) ?) ;
673
672
} else {
674
673
unreachable ! ( ) ;
675
674
}
Original file line number Diff line number Diff line change @@ -106,17 +106,8 @@ impl Rule for IndexSelectionRule {
106
106
let mut final_plan: PlanRef = logical_scan. clone ( ) . into ( ) ;
107
107
let mut min_cost = primary_cost. clone ( ) ;
108
108
109
- let required_col_idx = logical_scan. required_col_idx ( ) ;
110
109
for index in indexes {
111
- let p2s_mapping = index. primary_to_secondary_mapping ( ) ;
112
- if required_col_idx. iter ( ) . all ( |x| p2s_mapping. contains_key ( x) ) {
113
- // covering index selection
114
- let index_scan = logical_scan. to_index_scan (
115
- & index. name ,
116
- index. index_table . table_desc ( ) . into ( ) ,
117
- p2s_mapping,
118
- ) ;
119
-
110
+ if let Some ( index_scan) = logical_scan. to_index_scan_if_index_covered ( index) {
120
111
let index_cost = self . estimate_table_scan_cost (
121
112
& index_scan,
122
113
TableScanIoEstimator :: estimate_row_size ( & index_scan) ,
You can’t perform that action at this time.
0 commit comments