-
Notifications
You must be signed in to change notification settings - Fork 75
Query planner should use an index if available for any conditional #184
Comments
IIRC, that's correct. It's definitely feasible to use multiple indices, but it's not trivial. I've never even tried to start exploring that path. I'll provide full support to anyone willing to implement this. It would improve QL a lot. |
Crossing indexes is definitely non-trivial. What I was hoping to capture in this issue was that, in worst case, at least one index should be used if possible. In this case, If I get familar enough with the planner, I'll look at rewriting some sections - there are a good number of quirks in it, and its roughly the same layout as an interpreter, whose design i am somewhat familiar with. |
Definitely possible.
Sounds like a reasonable approach. |
Current state:
The TL;DR of this logic is that index will only be used in a small subset of applicable cases. Proposed Changes: type searchBound struct {
map[string][]columnCondition //maps column name to a set of conditions
}
type columnCondition struct {
minValue expr
maxValue expr
}
type whereConditional []searchBound The proposed implementation will scan the logic in the WHERE clause, generating a distinct list of Note that all WHERE clauses should be able to be simplified into this binOP OR binOP OR binOP two-layered form at runtime, so getting rid of the expr form simplifies determining bounds expressions.
For an index to be used for a given At runtime, the Query plans can be cached in a LRU cache if the intensiveness of this algorithm is of concern. All DBMS's do this. Thoughts? |
Additionally, this algorithm would go a long way to getting things ready for composite indexes in #183 |
SGTM. FTR: The interval package was intended for improving the planner but I never got so far as to actually use it. Maybe you will find it usefull. |
Are you a Googler by chance? All the googlers say that. :P I've started a new branch 'planner2' to work on this, gimme a few weeks. |
They do and I learned it from them. But I'm not a Googler.
Any time you need to make it happen is the right time ;-) |
You've got me very curious, but I won't probe :) |
The query planner should see that there is an index on the column
t
and use that instead of iterating all rows of tablet
.The current query planner will only use a index if it is non-composite, and where it is the first conditional in the
WHERE
clause.The text was updated successfully, but these errors were encountered: