Skip to content

perf(query): gate the bounded-multikey count+take fast path by table size#233

Merged
singaraiona merged 1 commit into
masterfrom
perf/q17-bounded-multikey-gate
Jun 8, 2026
Merged

perf(query): gate the bounded-multikey count+take fast path by table size#233
singaraiona merged 1 commit into
masterfrom
perf/q17-bounded-multikey-gate

Conversation

@ser-vasilich

Copy link
Copy Markdown
Collaborator

Summary

bounded_multikey_count_take_candidate triggers an eval-level
single-threaded scan
in ray_select_fn that walks every row with an
O(found) per-row linear group lookup. Profitable on small inputs
(skips the full DAG group HT construction) but for large multi-key
inputs the serial scan loses to the parallel mk_par_v2 fused_group
path.

ClickBench 10M q17 —

(select {c: (count UserID)
         from: hits
         by: {UserID: UserID SearchPhrase: SearchPhrase}
         take: 10})

— 10M rows × ~2.1M distinct composite keys. The query landed in the
eval-level path and spent ~340 ms on the linear scan even though the
result only needs any 10 (UserID, SearchPhrase, count) tuples.

Gate the candidate on nrows < 100000 so big inputs fall through to
the parallel filtered_group multi-key path.

ClickBench 10M:

q17  ~354 → ~161 ms   (-54%, -193ms)

Full 43-query sum: -207 ms / -6.7%.

Tests: 3241/3243 pass (unchanged).

…size

The bounded_multikey_count_take_candidate gate triggers an eval-level
single-threaded scan that walks every row with an O(found) per-row
linear group lookup.  Profitable on small inputs (skips the full DAG
group HT construction) but for large multi-key inputs the serial scan
loses to the parallel mk_par_v2 fused_group path.

ClickBench 10M q17 — `(select {c: (count UserID) by: {UserID,
SearchPhrase} take: 10})` over 10M rows with ~2.1M distinct composite
keys — used to land here and spend ~340 ms on the linear scan even
though the result only needs any 10 (UserID, SearchPhrase, count)
tuples.

Gate the candidate on `nrows < 100000` so big inputs fall through to
the parallel filtered_group multi-key path.

ClickBench 10M:

  q17  ~354 → ~161 ms   (-54%, -193ms)
@singaraiona singaraiona merged commit f2ae7ef into master Jun 8, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants