-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
opt: introduce placeholder fast path
Currently running a query with placeholders happens as follows: - at perparation time, we build a memo with the normalized expression *with* placeholders. - at execution time, we copy the expression into a new memo, replacing placeholders with their value (AssignPlaceholders). - then we run exploration which performs the actual optimization. For trivial queries like KV reads, we do too much work during execution (profiles show it is 10-20% of the runtime for KV workloads with high read rates). This commit introduces the concept of a "placeholder fast path". The idea is that we can make specific checks for simple expressions and produce (at preparation time) a fully optimized expression (which still depends on placeholders). For this, we introduce a new operator, PlaceholderScan which is similar to a Scan except that it always scans one span with the same start and end key, and the key values are child scalar expressions (either constants or placeholders). We use this new operator only for simple SELECTs where the filters constrain a prefix of an index to constant values; in addition, the index must be covering and there must be only one such index. With these conditions, we know the optimal plan upfront. For now, the placeholder fast path transformation is Go code; if it gets more complicated, it should be switched to use optgen rules. A benchmark on my machine shows a kv95 workload going from 34kiops to 38kiops with this change. Release note: None
- Loading branch information
1 parent
4c6e54e
commit 34d57a0
Showing
15 changed files
with
714 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.