Skip to content

Populate skipping_indices_types for session temporary tables - #2

Merged
CurtizJ merged 1 commit into
CurtizJ:system-tables-skip-indexesfrom
groeneai:fix/106388-temp-table-skip-indices
Jul 11, 2026
Merged

CurtizJ merged 1 commit into
CurtizJ:system-tables-skip-indexesfrom
groeneai:fix/106388-temp-table-skip-indices

Conversation

@groeneai

Copy link
Copy Markdown

Follow-up to the clickhouse-gh[bot] finding on ClickHouse#106388.

The TablesBlockSource temporary-table branch only special-cased parameterized_view_parameters, total_rows and total_bytes; every other late column fell through to insertDefault(). So the new skipping_indices_types column (position 20) always showed [] for session temporary MergeTree tables.

Fix: add a temp-table case for the skipping_indices_types slot, sharing a fillSkippingIndicesTypes() helper with the non-temp path (schema-derived, no extra hardcoded assumptions). Extended tests/queries/0_stateless/04311_system_tables_skipping_indices_types with a temporary MergeTree table with skip indices.

Verified locally (debug, build id 47a1fe57...): a CREATE TEMPORARY TABLE ... ENGINE = MergeTree ... INDEX idx TYPE minmax/set now reports ['minmax','set'] instead of []. Merge with one click and ClickHouse#106388 CI reruns.

The temporary-table branch in TablesBlockSource only special-cased
parameterized_view_parameters, total_rows and total_bytes; every other
late column fell through to insertDefault(). So the new
skipping_indices_types column at position 20 always showed [] for
session temporary MergeTree tables. Add a temp-table case for it,
sharing a fillSkippingIndicesTypes() helper with the non-temp path,
and extend the regression test with a temporary MergeTree table.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@CurtizJ
CurtizJ merged commit 3c69bff into CurtizJ:system-tables-skip-indexes Jul 11, 2026
CurtizJ pushed a commit that referenced this pull request Jul 28, 2026
CurtizJ pushed a commit that referenced this pull request Jul 30, 2026
The fix in this PR makes three FilterTransform call sites compose their
applied filter into ChunkInfoRowNumbers. Only the two stripped-PREWHERE
fallback filters were covered by 04615; the Iceberg equality-delete
notIn filter was not, so the equality-delete half of the contract was
unproven.

Reverting only the equality-delete call site to the old behaviour makes
the new test fail, and pristine master fails it too: on a table that
carries equality delete files the _row_number column is built from a
stale mask, which either aborts with a column length mismatch
("Expected the argument #2 ('__table1._row_number' of type Int64) to
have 423 rows, but it has 470") or silently yields compacted post-filter
indices instead of physical row positions. Those indices are what the
mutation path writes into positional delete files, so a wrong value
deletes the wrong rows.

The test uses the existing committed fixtures: deletes_db/eq_deletes_table
(equality plus position deletes, also read under PREWHERE so the fallback
filter stacks on top of the notIn filter) and
deletes_db/eq_deletes_required_table (equality deletes only, where the
exact physical row numbers are asserted). The per-file offset assertion is
independent of the engine path: it is checked against the raw Parquet data
files read directly through s3().

Co-Authored-By: Claude Fable 5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Aug 21, 2026
A query flagged in `report.html` was dropped when `all-query-metrics.tsv` had
no `client_time` row for it, and a shard whose TSV could not be read dropped
all of its flagged queries. With every flagged query dropped the run ended with
"the comparison ran and was clean" - a non-empty CI report turned into an
all-clear. The cause is deliberate on CI's side: `compare.sh` retracts a query
from the TSV when its confirmation rerun demoted it, while the report still
lists it under both "Changes in Performance" and "Unconfirmed Changes". On
PR ClickHouse#115255 that is `round_down` #2 and #3 and `and_compare_chain_derived` #2.

Those rows carry their own numbers, so they are now read from `report.html` and
marked `*` in the report - CI's verdict on them was already in doubt, which
makes them the most interesting queries to rerun, not the ones to discard. A
flagged query readable from neither source is reported as unresolved, and if
that leaves nothing to rerun the run fails instead of reporting a clean
comparison.

The commit under test drove only the report and binary lookup; the XMLs,
`perf.py`, its `stat_threshold`, and the configs still came from the working
tree. Query indices are positional and substitutions expand them, so a tree
that differs from the measured commit silently reruns a different query - on a
checkout one commit behind master, `and_compare_chain_derived.xml` has no query
#2 at all while CI flagged exactly that, and a `refs/pull/<n>/merge` checkout
is never the commit CI measured. `tests/performance`, `programs/server` and
`tests/config/top_level_domains` are now extracted from that commit into the
work dir and everything runs from there, fetching the commit when the clone
lacks it. `--use-working-tree-tests` opts out for iterating on a local test.

Verified: all six flagged queries of PR ClickHouse#115255 are now kept, the three the TSV
retracts carrying the report's numbers and flagged as unconfirmed; a dry run of
PR ClickHouse#112688 recovers `date_time_64` #5, which had been dropped the same way, and
runs against the extracted tree.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=115278&sha=baefff6dcc4dbb3201337a52b5ca54453fb34562&name_0=PR&name_1=Style%20check
Pull request: ClickHouse#115278

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GYYbBbrQpmi2zkYJ8LQw5Z
alexey-milovidov pushed a commit that referenced this pull request Sep 8, 2026
Address review on 03480_year.sql and year.cpp:

- The query-result-cache section is gone; determinism is asserted from
  `system.functions` (`year 0 <empty alias_to>`), which is a direct read of the
  flag rather than an observation of one of its consumers.
- `no-parallel` goes with it. The tag was earned only by the query result cache
  being a global singleton; what is left creates one table in the test's own
  database and reads `system.functions`, so it is safe to run against itself.
- The `year(datetime, timezone)` case is removed from the test, and the
  timezone argument is removed from the documented signature, the arguments
  list and the examples. Only the one-argument form is documented now.

Dropping the timezone example renumbers the remaining ones, so the
`docs_examples` baseline entry for the current-year example moves from
`Function/year#2` to `Function/year#1`. Left at `#2` the runner reports it as a
known failure that no longer exists, which fails the job.

The index-analysis statement gains a `pruned` column. Comparing the two row
estimates for equality also holds when neither spelling prunes: on the same
fixture with `ORDER BY tuple()` both estimates are 40000, so `same_index_scan`
is 1 while `pruned` is 0.

Co-Authored-By: Claude Opus 5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Sep 24, 2026
Review asked to keep the block sizes always a power of two, so the fill's
`max_block_size` moves from 65409 to 65536. It now matches the
`max_insert_block_size` beside it and
tests/performance/join_convert_full_to_left_or_right.xml, which pins the same
pair at 65536.

65409 was the current default of the setting (`DEFAULT_BLOCK_SIZE` in
src/Core/Defines.h, 65536 minus the SIMD padding), so the pinned value is now a
deliberate round number instead of a restatement of that default. The comment
dropped the sentence naming 65409 as the default, which the swap makes false,
and states the invariant the pin buys instead.

Nothing the test asserts or measures changes. Both tables still write 16 active
parts, so the `throwIf` oracles stand; the cut moves from 15 x 65409 rows +
18865 to 15 x 65536 + 16960. Measured with `EXPLAIN indexes = 1` on all three
queries, 65409 -> 65536:

  #0  parts 3/16 unchanged, index range 39246 -> 39321 granules, read 3 -> 3
  #1  parts 1/16 unchanged, read 1 -> 1
  #2  parts 12/16 unchanged, 156984 -> 157284 granules, read 133114 -> 133110

The +0.19% is the range the skip index walks, not the data read. With both
sides at one layout the worst arm spread measured on #0 is +9.6% over 5537
jobs, against the check's 15% floor, so the shift is far below either.
CurtizJ pushed a commit that referenced this pull request Sep 30, 2026
These queries were flagged as slower/faster/unstable on master runs, or scored as confirmed regressions by the performance dashboard on unrelated PRs, because the two compared servers did not measure the same work:

- `and_compare_chain_derived`: both tables are created with `numbers_mt`, which writes a varying number of parts, and the measured runs stop merges, so the servers read different layouts (the join query took 34 ms over 17 parts and 82 ms over one part on the same binary). Merge each table to one part and check it. Query 2 now keeps 2M rows per side (`8000000 < l.v`) and runs at about 150 ms instead of 20 ms.
- `set_index`: the IN set was built from `rand`, so every run looked up a different set, selected different ranges and read a different number of rows before `read_overflow_mode = 'break'`. Use a fixed pseudo-random sample (`toUInt32(cityHash64(number))`) and merge the 500M-row table to one part.
- `formats_columns_nullable`: `SELECT * ... LIMIT 1000` read 6-10 ms, and parallel parsing parsed a varying amount ahead before the LIMIT cancelled it (`LIMIT 30000` of CSV took 197 ms with it and 38 ms without). Disable parallel parsing for that query and read 100000 rows, about 200 ms for text formats.
- `serialization_pool_lookup`: the fixed `max_threads = 16` oversubscribed the 8 pinned cores of the amd runners; query 0 was flagged in 9.3% of amd master runs against 0.4% on arm. Use the harness default of one thread per pinned CPU.

Master flag rates over 14 days (slower/faster/unstable share of master runs): `and_compare_chain_derived #2` 5-8%, `set_index #0` 14% (arm), `formats_columns_nullable #1` 19% (arm), `serialization_pool_lookup #0` 9% (amd).
CurtizJ pushed a commit that referenced this pull request Sep 30, 2026
…ion over a `Nullable` argument

The `-If` null adapters merged the null map with the condition into a buffer
sized by the absolute end row of the call and filled only `[row_begin, row_end)`.
Aggregation in order calls `addBatchSinglePlace` once per key interval, and
window frames once per frame update, so with 8-row groups every call asked for
up to 64 KiB to use 8 bytes. The merges the nested functions do for themselves
(`SingleValueData`, `groupBit*`, the simple moments, `regr_*`,
`timeSeriesLastTwoSamples`) were sized the same way.

On x86_64 every such request above 32 KiB exceeds jemalloc's thread cache
limit (`opt_tcache_max`) and takes the arena large-extent path, whose cost
depends on the state of the process. On aarch64 (64 KiB pages) these sizes are
small size classes served from the thread cache. That is why queries #2 to #5
of `tests/performance/aggregation_in_order_if_null_map.xml` are unstable on
the amd runners only: in the last 14 days CIDB has 2008 of the test's 2174 amd
`unstable` verdicts on #2 to #5, and 8 on arm in total.

With a single `Nullable` argument no merged map is needed:
`addBatchSinglePlaceNotNull` takes the null map and the condition column
separately, and every implementation handles `if_argument_pos`
(`AggregateFunctionIf` already calls them all that way). So
`AggregateFunctionIfNullUnary` with a non-`Nullable` condition passes the
value's null map and the condition at position 1, and
`AggregateFunctionIfNullVariadic` with exactly one `Nullable` argument passes
that argument's null map to the nested `-If` function, which applies the
condition. The merges those calls reach allocate `row_end - row_begin` bytes
and call their kernels with pointers rebased by `row_begin`, as `sum` and
`avg` already do. The same rows are added in the same order, so the results
do not change. Two or more `Nullable` arguments (query #5, `corr(x, w)`), a
`Nullable` condition of a one-argument `-If` function and the TimeSeries
array merges keep their merged buffer.

Measured on a release build (x86_64, `max_threads` 8), base / this change,
per run of each query of the test:
- jemalloc large allocations above 32 KiB: #0 703 / 703, #1 714 / 714,
  #2 302182 / 703, #3 302142 / 663, #4 229046 / 1718, #5 115413 / 115413;
- CPU profiler samples in the jemalloc large-extent path: #2 33% / 0.9%,
  #3 31% / 0.5%;
- perf.py median of 13 runs, two alternating rounds (ms): #2 38.2, 39.8 /
  24.6, 21.7; #3 39.0, 40.2 / 21.3, 19.8; #4 44.3, 45.4 / 28.3, 25.9;
  #0, #1 and #5 unchanged;
- `minIf(x, cond) OVER (ORDER BY k ROWS BETWEEN 100 PRECEDING AND CURRENT
  ROW)` over 1M rows: 340 / 166 ms, and `sumIf(y, cn)` over a `Nullable`
  condition: 301 / 89 ms;
- aggregation without keys over the same table: 12.2 / 12.3 ms.

Query #0, flagged on ClickHouse#118490,
never had such a buffer and is not changed here.
CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=118490&sha=8ded98e22889e53dd536b141b564e136c76482a9&name_0=PR&name_1=Performance%20Comparison%20(amd_release%2C%20master_head%2C%203%2F6)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Sep 30, 2026
Query #0 groups 5M rows by a single-type Dynamic key. For every row the
aggregation looks up the variant's default serialization in
SerializationObjectPool: a shared lock on the key's shard mutex,
weak_ptr::lock, and the release of the returned SerializationPtr. These
are atomic read-modify-writes on two cache lines that every aggregation
thread writes for every row. One key means one shard, so the pool's
sharding cannot spread the load, and the query is bound by how fast those
lines move between cores. That speed is fixed per server process.

CI data (query_metric_runs_v1, arm, 1177 runs since 2026-09-17): the 5-7
samples of one server agree within 0.7% (p50), but the per-process medians
span 0.643-0.840 s (p05-p95). Fast and slow processes do the same work
(same arena bytes, memory, two-level hash tables and page faults) and
differ only in user CPU time (9.5 vs 12.1 s). The wall time does not
depend on the thread count: arm 0.754 s with 16 threads vs 0.775 s with
12, amd 0.669 s with 16 threads on 8 pinned cores vs 0.686 s with 8. So
each A/B run compares two random draws of that per-process speed. Runs
whose new/old median moved by more than 15% (raw samples):

                                 arm PR   arm master   amd PR   amd master
    serialization_pool_lookup #0  123/789     54/558    68/176     220/560
    serialization_pool_lookup #1   41/789     11/558     5/176      20/560
    serialization_pool_lookup #2    0/789      0/558     0/176       0/560
    group_by_dynamic_keys #0        0/782      0/559     0/173       0/559

group_by_dynamic_keys #0 runs the same per-row lookup path with
max_threads = 1. On PR ClickHouse#117533 the performance dashboard scored #0 as a
confirmed regression (arm 5/6, 0.670 -> 0.799 s) that the shard's own
report did not flag.

Run #0 in one thread, from numbers instead of numbers_mt, so it times the
pool's hit path itself, which does not depend on the process. Queries #1
(two keys, where sharding spreads the load) and #2 (the multi-threaded
MergeTree read) keep the contention coverage.

Local check on x86 with the official 26.10.1.820 master build, perf.py,
7 runs: old #0 1.76 s with 12 threads (15.4 s user CPU per run), new #0
0.57 s (0.56 s user CPU), same result. Ten fresh servers pinned to 8
cores with max_threads = 8: old #0 per-process medians 0.68-1.08 s; new
#0 0.56-0.58 s in 8 of them and 0.72-0.73 s in the two whose table
fills were also about 25% slower (9.2-10.0 s vs 7.4-8.6 s).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Sep 30, 2026
…columns performance test

`least_greatest_const_columns #2` returns the 256-byte constant `repeat('d', 256)` for every row, so
the result `ColumnString` grows its `chars` by power-of-two `realloc` up to 16 MiB per block. Whether
jemalloc grows that buffer in place or moves and copies it (`large_ralloc` -> `memcpy`) differs
between server processes, and in CI CPU profiles that copy is the only part of the query whose sample
count differs between the two servers. In 14 days the two servers differed by more than 15% in 94 of
775 amd and 23 of 1692 arm runs of this query, and in none for `#3`, which takes the same arguments
with `least` and returns the ~7-byte `toString(number)`.

Add a constant `'e'` that wins every row, so the result is one byte per row. The query still compares
`toString(number)` against the four 256-byte constants that are not materialized since ClickHouse#119108, and
still returns a constant argument.

Failing job: https://github.com/ClickHouse/ClickHouse/actions/runs/36432228454/job/109047348805
PR: ClickHouse#122184

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 3, 2026
…nce per block

`mortonEncode` with two arguments ran one row loop for every argument type
and mask: per row and argument it tested the mask and `is_const`, reloaded
the ratio, switched on the column width and, with a mask, called the
out-of-line `expand` (36 call sites in the arm `executeImpl`). On arm the
speed of the branch-dense paths depends on the binary's layout, so
`space_filling_curve` #1 (constant mask) and #4 (`UInt32` arguments) have
per-build speed modes and flag unrelated PRs in Performance Comparison
(ClickHouse#122482), while #2 (two `UInt64` columns) is stable.

Now each argument is resolved once per call into a contiguous `UInt64` array
with the range expansion applied: a `UInt64` column that needs no expansion
is read in place, other widths are widened with one type dispatch, and a
constant ratio is applied in one loop per ratio value (`expand` is
`ALWAYS_INLINE` and called with a template-constant ratio, so its switch
folds). A per-row mask keeps the per-row `expand`. `nd == 1` writes the
result column directly. The encode loops only encode.

x86, one core, median fix/base of 5 interleaved rounds over the queries of
`space_filling_curve.xml`: #1 0.57 (BMI2) / 0.55 (lookup-table path, built
with `-mno-bmi2`), #2/#3/#6 0.45-0.64, #4 0.86-0.88, untouched functions
0.99-1.03. Results are unchanged: 545 checksums over every width, mask and
ratio are byte-identical before and after on both code paths, and the new
test fails on both paths under two mutations of the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 3, 2026
…test

The two compared servers each built a different copy of the fixture:

- `rand64() % 5000000` makes the number of rows with key 5, which queries
  #1 and #3 look up, a fresh draw per server (0 to 3 over 10 local fills);
- each INSERT is squashed into ~5 parts (cut at min_insert_block_size_rows),
  which merge until perf.py's --stop-merges freezes them at a per-server
  point.

#1 and #3 read about one granule per part, so each server read its own
number of granules: in CI the servers read different parts in 80% of runs,
and time follows the rows read (correlation 0.85-0.88). This redded
unrelated PRs (e.g. ClickHouse#118662, arm 4/6, #1 +37.5% confirmed_regression) and
inflated the learned threshold of #1/#3 to 0.41-0.53 (0.04-0.09 for
#0/#2/#4 on the same tables); the dashboard now caps both at
likely_regression as "Flaky lately", so a real regression there cannot red.

Use deterministic data, cityHash64(number, 7) and cityHash64(number, 11)
modulo 5000000 (same key range and duplicate profile; the seeds put key 5
once in each table, the modal case of the random draw, so #1/#3 keep
measuring a non-empty point join), and write each table as one part with
min_insert_block_size_rows = 10000000, min_insert_block_size_bytes = 0
(5M rows give one squashed block). A throwIf on system.parts fails the
fill if the layout ever drifts. Same shape as ClickHouse#122479 and ClickHouse#122660.

Validated through perf.py --stop-merges on two servers, 5 fresh fills per
arm: new fixture identical on all 10 server fills (one part per table, same
data, #1/#3 read 2 granules on both, #0/#2/#4 read 10M rows); old fixture
different on all 5 iterations. Without the insert settings the throwIf
fails the fill.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 3, 2026
On x86, returning the rescan of the matching block from inside the block loop
is unrolled into branchless code that reuses the comparisons of the block.
Rescanning after the loop made it a loop whose exit is mispredicted when the
match position varies: `array_index_simd_numeric` #2 got 36% slower on amd.
Return from inside the loop on x86 again, so its code is the same as before
this PR. Other targets keep the `break`, which ARM needs to vectorize the block
loop for 4- and 8-byte elements (the same query got 25% faster on arm).

Related: ClickHouse#123377

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 3, 2026
Since ClickHouse#122458 the first query of the test (#0-ClickHouse#7, one per format) is
SELECT * ... LIMIT 100000 with input_format_parallel_parsing = 0, so the
text formats are parsed in one thread. On ARM the speed of that parse is
fixed per server process: the 7 runs of one server agree within 1-2%,
while different servers take 0.26-0.55 s for #2 (JSONEachRow). In the
failing job on ClickHouse#101022 (+54.9%, 0.338 -> 0.524 s) the confirmation
restart drew new levels for both servers (0.293 and 0.345 s), and the
slow side read the same rows and bytes with 1.58x the user CPU. #1 and #2
share the factor within a process (r = 0.86); it does not reach the
other 80 queries of the same processes, which read the same files with
parallel parsing. Why the single-threaded parse is per process on ARM is
not established.

Runs whose two servers differ by more than 15% (query_metric_runs_v1,
raw samples, since 2026-09-27):

                         arm PR   arm master   amd PR   amd master
    #0 TSVWithNames      38/200      5/33       0/48       0/42
    #1 CSVWithNames     111/191     19/35       0/42       0/30
    #2 JSONEachRow      112/199     15/31       0/34       0/32
    #3-ClickHouse#7 binary          1/982      0/188      0/180      0/185

The 80 parallel-parsing queries on the text formats: 0 of 7232 ARM runs.

Read the whole file with the default parallel parsing instead: without a
LIMIT the amount parsed does not depend on read-ahead (why ClickHouse#122458
disabled parallel parsing), and no text format is parsed in one thread.
Avro has no parallel parsing, so #3 now takes about 2.7 s on ARM
(report-only "too long"; ClickHouse#75 of this test is already 2.16 s). The text of
#0-ClickHouse#7 changes, ClickHouse#8-ClickHouse#87 are unchanged.

Local check on x86 with the official 26.10.1.1403 master build, server
pinned to 16 cores with max_parsing_threads = 16, perf.py, 7 runs: new
#0-#2 0.43, 0.47 and 0.96 s with 3% spread, #3 2.15 s, #4-ClickHouse#7 0.09-0.53 s;
every query reads all 2000000 rows of the file, #0-#2 in 7-15 threads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 4, 2026
…n appending

The cache corruption had TWO root causes that both needed to be fixed:

1. **Caching without cloning**: When caching a column without appending
   (column_sizes_before == 0), the code directly assigned res_columns[pos]
   to column_to_cache. Even though column_to_cache was later moved into
   the cache entry, res_columns[pos] still pointed to the SAME column object.
   When the caller reused res_columns across multiple readRows() calls,
   any mutations would corrupt the cached data.

   Fix: Clone the column before caching using cloneResized() to ensure
   the cache has an independent copy.

2. **Appending without proper mutation**: When serving from cache with
   append=true, the code used assumeMutable() which does NOT check use_count.
   This returned a mutable reference to a shared column, allowing
   insertRangeFrom() to modify cached data in-place.

   Fix: Use IColumn::mutate(std::move(...)) which properly handles shared
   columns by cloning when use_count > 1.

Both fixes are necessary:
- Fix #1 prevents corruption at cache write time
- Fix #2 prevents corruption at cache read time with column reuse

This fixes all 4 failing cache tests that showed corrupted sums
(2737387281 instead of 4999950000).

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 5, 2026
…e test

Query #1 (`FINAL WHERE v = 7 LIMIT 100`) never reaches its limit: only 47 rows
survive FINAL, so it scans all of (k, v) and lazily reads `payload` for those
47 rows. With default granules (~5-6K rows of 2 KB random, incompressible
strings, ~10 MB each) every match decodes ~6 MB of payload, ~285 MB in total.

After ClickHouse#122479 both compared servers read identical data, but on arm one server
of a pair still copies those same bytes out of the page cache ~20% slower in a
few percent of fills, and with merges stopped all runs of the query carry it:
PR ClickHouse#122571 got a confirmed +17.8% on `Performance Comparison (arm_release,
master_head, 6/6)` this way.

With `index_granularity = 256` a granule is ~0.5 MB and one compressed block,
so each match reads ~0.5 MB. Measured on a two-server rig with the XML's own
statements: #1 ReadCompressedBytes 284.1 MB -> 31.8 MB, SelectedRows 1,015,104,
#0 and #2 read less too (58.7 -> 13.3 MB). The test still measures FINAL over
the same two intersecting parts with lazy materialization of the wide payload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Oct 10, 2026
…ce test

Query #1 cast a String to JSON inside the measured query, so most of its
CPU (about 80% in the arm CI profile, 72% on x86 locally) went to the
JSON parser rather than to the serializing hash the test exists for. The
parse has a per-server-process slow mode, so a slow draw on the tested
server read as a hashing regression and turned unrelated PRs red
(Performance Comparison on ClickHouse#117318: +15.8%, gone after a server restart).

Build the JSON column once at fill time in a Memory table and hash the
stored column, single-threaded as before and as in query #2. JSON parsing
itself stays measured by new_json_type.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ added a commit that referenced this pull request Nov 10, 2026
…roximate dense ones

The analysis decoded single-segment `pfor` and `bitpacking` posting lists into a Roaring bitmap
before folding them, which made `pfor` much slower than `none` on dense lists (perf test
`text_index_trivial_count`, queries #2 and #3).

- `FoldedPostings`: the rows of block-compressed posting lists are decoded straight into sorted
  arrays, no bitmap is built. An intersection is a sorted array, intersected with a compressed
  posting list without decoding the blocks with none of its rows. A union is kept as its largest
  array and the merged other arrays, so the rows of a dense list are not copied: its cardinality
  is counted from both, and the lazy readers take a cursor per array.
- `approximatePostings`: a dense posting list of an `Any` or single-token query is approximated by
  the row spans of its packed blocks. The last row of a block is a row of the posting list, so only
  a block whose span holds a whole mark needs decoding, and the approximation is exact at the
  granularity of marks. The readers read such posting lists themselves with cursors, so it is used
  only in the lazy mode without patterns, and not by `ReadFromTextIndexCount`.
- New event `TextIndexAnalysisApproximatedPostings`, test 05616.

Related: ClickHouse#127489 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Nov 16, 2026
The collation sort (#2, 5M rows) and the single-column string sort (#3,
20M rows) take 1.2-1.9 s on MasterCI on both arches. They get
disabled="1" (text and number unchanged) and are appended as ClickHouse#9 and ClickHouse#10
on a quarter of the rows with max_block_size = 16384, a quarter of the
default 65409. `numbers_mt` hands out blocks of exactly max_block_size
rows, so each copy has as many blocks as its original (77 and 306): the
same number of cursors in every per-stream merge and the same 16-stream
final merge, with a quarter of the rows per block. EXPLAIN PIPELINE of
each original and its copy is identical (16 streams).

Measured on official MasterCI release builds, two servers pinned to 24
cores of one NUMA node, perf.py, 25 runs: copy / original time 0.248
(#2) and 0.252 (#3), projected CI medians 380 / 487 ms amd, 298 / 483 ms
arm. On the builds before/after ClickHouse#115869 (sorted array of cursors) #2 is
1.161x faster and its copy 1.159x; on those before/after ClickHouse#126829
(cheaper collation) 2.179x and 2.111x; #3 and its copy show no change
on either pair (1.005 / 1.008, 1.004 / 1.001), as the heap guard should.

#0 and #1 stay as they are: on this rig the ClickHouse#115869 change did not show
on them beyond the A/A resolution, so there was no measured guarantee
that copies would keep their sensitivity.

About 32 s (amd) and 29 s (arm) of query time less per master
performance job; 9 queries stay enabled, so all of them still run.

Related: ClickHouse#129258

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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