Repository navigation
Add a memory_prewhere query with a condition on a wide selected column - #123155
Conversation
The query is shaped like ClickBench Q37: a selective condition on a narrow column next to `s2 != ''`, with `s2` also selected. Because `s2` is selected, the condition reads the whole column rather than its `size` subcolumn, so it shows whether `Memory` decompresses the wide column for every block (a single PREWHERE step) or only for the blocks where the selective condition has passing rows (multiple steps). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Workflow [PR], commit [520c7ba] Summary: ✅
AI ReviewSummaryThis PR adds a new Findings
Final Verdict
|
| `CounterID = 62`). The query also selects the wide column, so the condition reads the whole column, | ||
| not its `size` subcolumn. With a single PREWHERE step the column is decompressed for every block; | ||
| with multiple steps only for the blocks where the selective condition has passing rows. --> | ||
| <query tag='selective, with a condition on a wide selected column'>SELECT s2, count() FROM mem_prewhere WHERE filt BETWEEN 1000000 AND 1000100 AND s2 != '' GROUP BY s2 FORMAT Null</query> |
There was a problem hiding this comment.
The contract for a perf query here is “long enough to produce a stable signal”. The PR description says this new case is about 0.025 s on current master, but tests/performance/scripts/README.md asks perf queries to stay above 0.1 s because shorter ones get noisy. That makes this a weak baseline for #122604: it risks surfacing as an unstable / too-short benchmark instead of reliably measuring the PREWHERE wide-column regression. Please scale the workload up until it is comfortably above the floor on CI hardware (for example more rows, a wider filt window, or max_threads = 1).
There was a problem hiding this comment.
We support short queries as well.
The query added earlier filtered on `s3 != ''` without selecting `s3`, so the optimizer rewrote the condition to `s3.size != 0`, which reads only the cheap `size` subcolumn, and the query did not exercise the change (28.4 -> 28.7 ms in the performance check). Use the same query as #123155, which selects the column it filters on, so that the two PRs make an identical change to the file. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Adds a query to
tests/performance/memory_prewhere.xmlthat measures a condition on a wide column next to a selective one, shaped like ClickBench Q37 (URL <> ''next toCounterID = 62).The query selects the wide column as well as filtering on it (
SELECT s2, count() ... WHERE filt BETWEEN ... AND s2 != '' GROUP BY s2). That makes the condition read the whole column. If the query only filters on the column, as the query added in #122604 does withs3, the optimizer rewrites the condition tos3.size != 0and reads only the cheapsizesubcolumn, so the test never exercises the wide-column case. That query showed 28.4 → 28.7 ms in #122604's performance check.On current master, the whole conjunction is one PREWHERE step (
notEmpty(s2) AND filt <= 1000100 AND filt >= 1000000), sos2is decompressed for every block. On a master binary, 20M rows, this query takes 0.025 s, against 0.007 s whens2 != ''is kept out of PREWHERE (explicitPREWHERE filt BETWEEN ...). Merging this first gives #122604 a baseline to show the multi-step improvement against.Related: #122604
Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/123155]
Version info
26.10.1.1188-master(included in26.10and later)