-
Notifications
You must be signed in to change notification settings - Fork 617
Invalid Index Scan Plan Selection with Multi-column Indexes #1299
Comments
peloton/src/optimizer/rule_impls.cpp Lines 241 to 253 in 78b85dc
This is probably the cause of the issue. The |
Gustavo, Thanks! I looked at the code you pointed and I think the issue is here. peloton/src/optimizer/rule_impls.cpp Line 394 in 78b85dc
Here, we are just checking if the given column is present in the column set of the index object but not enforcing any order in the matches. Instead, we should take the vector of column oids present in index catalog object (this preserves multi-column order as specified by the user) and check in the given order if there is any match with the columns given in the query predicates. Something like this?
This seems to work. |
As part of our class project "Index Selection", we are trying to generate multi-column hypothetical indexes and checking the cost of using them for a query.
The optimizer does not select a valid plan with multi-column indexes. If we create a multiple-column index say Index1 on columns say (a, b, c) on a table T, and if a query has a where clause on only (b), then the optimizer chooses Index1 in its best plan for the query. Same goes with (c) as well. Ideally, Index1 should only help queries with (a) or (a, b) or (a, b, c) as the where clause predicates. Surprisingly, even with the wrong plan, the query executed successfully.
Steps to reproduce:
Query plan
Plan Type: INDEXSCAN
Info: IndexScan
NumChildren: 0
(5 rows)
a | b | c | d | e
---+---+---+---+---
4 | 5 | 6 | 7 | 8
(1 row)
The text was updated successfully, but these errors were encountered: