perf(query): fuse no-WHERE multi-key count-only group-by#218
Open
ser-vasilich wants to merge 2 commits into
Open
perf(query): fuse no-WHERE multi-key count-only group-by#218ser-vasilich wants to merge 2 commits into
ser-vasilich wants to merge 2 commits into
Conversation
The fused multi-key path already accepts a NULL predicate; only the planner gate required where_expr. Allow no-WHERE when n_keys >= 2 AND count-only. Single-key no-WHERE and multi-agg over near-unique composites stay on exec_group's radix — fusing them regresses at very high cardinality. ClickBench 10M: q16 744 → 154 ms total 8.0 → 7.3 s Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
mk_compile packs the composite by-key into a 16-byte slot. An I64
column for minute() (values 0..59) blows the budget on q18's
{UserID, minute, SearchPhrase} composite (~20 bytes) and the query
drops to exec_group.
After eval'ing a computed by-val whose AST head is minute / hh / ss /
dd / dow / mm / doy / yyyy, downcast the I64 result to I16 before
adding it to the table. I16 is the smallest type that holds every
output range (year up to 32767, doy up to 366) and still prints as
decimal (U8 prints hex, unreadable for a minute value).
Skipped when the source column has nulls.
ClickBench 10M:
q18 1748 → 449 ms
total 6.6 → 5.2 s
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
f1cf38d to
fe96af0
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relax the fused group-by planner gate so a no-WHERE multi-key
count-only shape routes onto
exec_filtered_group_multiinstead ofthe unfused
exec_groupradix path.ray_filtered_groupalreadyaccepts a NULL predicate (worker runs with a const-true mask); the
only blocker was
where_expr &&in the gate.Gate now fires no-WHERE only when
n_keys >= 2 && has_only_count.Single-key no-WHERE and multi-agg over near-unique composites stay on
exec_group— at very high cardinality the radix path'sper-(worker, partition) scatter beats a single linear-probe shard.
Follow-up commit: narrow I64 results of known-small temporal extracts
(minute / hh / ss / dd / dow / mm / doy / yyyy) to I16 before adding
to the table. Brings q18's composite under the 16-byte mk_compile
budget so it fuses too.
ClickBench 10M: