Skip to content

Exclude implicitly created skip indices from system.tables.skipping_indices_types - #4

Merged
CurtizJ merged 1 commit into
CurtizJ:system-tables-skip-indexesfrom
groeneai:fix/106388-exclude-implicit-indices
Jul 13, 2026
Merged

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

Conversation

@groeneai

Copy link
Copy Markdown

Addresses the clickhouse-gh[bot] review finding on ClickHouse#106388.

fillSkippingIndicesTypes() aggregated all getSecondaryIndices(), which includes implicitly added skip indices (e.g. from add_minmax_index_for_numeric_columns = 1), not just explicit INDEX clauses. So a table with the auto-minmax setting but no explicit index reported ['minmax'], contradicting the documented contract (types defined on the table) and giving false positives to tooling that checks skipping_indices_types != [].

Fix: filter !index.isImplicitlyCreated() in the helper, so both the non-temp and temp-table paths report only user-defined skip-index types. Mirrors how the create statement omits implicit indices and how system.data_skipping_indices marks them via its creation column.

Test: extended 04311_system_tables_skipping_indices_types with a table using add_minmax_index_for_numeric_columns = 1 and no explicit index (must be []) and one with the setting plus an explicit set index (must be ['set']).

Verified locally: system.data_skipping_indices shows the auto-minmax indices as Implicit while system.tables.skipping_indices_types now returns []. Full test passes.

…indices_types

getSecondaryIndices() includes implicitly added skip indices (e.g. from
add_minmax_index_for_numeric_columns) as well as explicit INDEX clauses.
The column is documented as the skip-index types defined on the table, so
filter out index.isImplicitlyCreated() to report only user-defined types.
Matches how the create statement (IndicesDescription) omits implicit indices
and how system.data_skipping_indices marks them via its creation column.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@CurtizJ
CurtizJ merged commit a50c8e9 into CurtizJ:system-tables-skip-indexes Jul 13, 2026
alexey-milovidov added a commit that referenced this pull request Aug 30, 2026
…is not an entry

**Same-cycle detection now has a durable source.** `cycle_entries` was built
from what the changelog still shows - the section, this run's raw entries, the
recorded deletions, the revert graph - and an entry pruned as insignificant on
an earlier run leaves none of those. A revert of it arriving weeks later
therefore looked like a revert of an earlier release: deleting it was rejected,
or keeping a visible bullet for a change with no net effect was accepted.

`release_range_prs` answers the question from git instead: the pull requests
merged into master since the cycle's `vX.Y.1.1-new` tag, from both subject
shapes the repository uses. Git remembers the range whatever the changelog did
with it. `--first-parent`, so the walk stays on master's own commits - a
contributor branch can carry merges of pull requests of the contributor's
*fork*, and there are five such numbers in the 26.8 range (`Merge pull request
#4 from someone/...`), which mean nothing here. 2277 pull requests for that
range, in 0.3s.

**And the limitation from the previous round is closed rather than documented.**
A re-applier that also reverted something of an earlier release has a change of
its own; the link it contributes to the entry it brought back is an annotation
on someone else's bullet and cannot stand in for that. It is checkable without
forbidding a legitimate merge, by asking for *some other* bullet rather than
for a bullet of its own: a section 7 merge into a third entry still passes,
while collapsing the entry into the annotation does not.

Two tests added. The pruned-entry one runs the same input with and without the
range, so it shows both the old verdict and the new one; the annotation one
also asserts that the legitimate merge is still accepted.
alexey-milovidov added a commit that referenced this pull request Aug 30, 2026
…ategory

**`release_range_prs` read every `(#N)` in a subject.** A squashed revert
quotes the original title, `Revert "Something (ClickHouse#90000)" (ClickHouse#115800)`, and the
quoted number would put a pull request of an earlier release into this range -
the very distinction the caller uses the range for, so a revert of it would
look like something this release cancels out rather than a user-visible
reversal. Both shapes are now anchored: the squash number ends the subject, the
`Merge pull request #N` one starts it.

That shape does not occur in the last 60000 commits of this repository, where
reverts land as merge commits, so this is hardening rather than a live bug. The
anchored form is the right parse either way, and the regression pins it along
with a fork's own `Merge pull request #4` appearing mid-line.

**A sibling moved between categories made the merge impossible.** The category
check demanded the recorded header while the shared-bullet rule demanded a
merge into the surviving bullet, so once an edit had moved that bullet the two
contradicted each other and no edit could pass. The expected category is now
the surviving bullet's current one when there is a sibling to merge into, and
the recorded one otherwise: the check follows the bullet rather than a
remembered header.

The two rules then compose instead of fighting - moving the whole merged bullet
elsewhere stays legal, while leaving the survivor and restoring the entry beside
it under the old header is rejected, which the test asserts.
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 ClickHouse#7 of tests/performance/array_first_last.xml (arrayLast over
Array(Array(UInt64))) takes a different time in each server process of
the same build. In 14 days of Performance Comparison runs on amd it moved
by more than 15% between the two servers in 50 of 633 runs, 36 of them
master against master, while #6 (arrayFirst over the same column) moved
in 0 of 641 and the tuple queries #4/#5 in 2 and 3; arm is quiet. Per
run, #6 and ClickHouse#7 move in opposite directions (r = -0.53 over 524 amd runs;
in 33 of the 37 runs where ClickHouse#7 moved by more than 15%, #6 moved the other
way), while #4/#5 move together (r = +0.42).

Each nested_values row holds 32 inner arrays of 2 UInt64, so rows are 256
bytes apart in the inner offsets and 512 bytes apart in the data. #6 and
ClickHouse#7 read one inner array per row, so for the whole query every row is read
at the same position modulo 256/512 bytes, i.e. at the same few offsets
inside every memory page. Which offsets those are depends on where the
column is allocated: jemalloc is built with cache_oblivious, which puts
every large allocation at a random multiple of 64 bytes inside its first
page, and the table is filled once per server. So each server reads the
column at its own fixed page offsets.

Fill nested_values with 31 inner arrays per row. Rows are then 248/496
bytes apart and the read position walks through every offset of the page
within one query, so the timing no longer depends on the allocation. The
query texts and the per-row work (one copy of a 2-element array per row,
250000 rows) are unchanged.

Local check with the official master build 26.10.1.906 on a Xeon 6975P-C:
16 separately filled copies of the table per arm in one server, measured
round-robin for 20 rounds. This machine does not show the spread with
either layout (ClickHouse#7 across copies: 14.14-14.68 ms with 32 elements and
random allocation offsets, 13.93-14.27 ms page-aligned with
MALLOC_CONF=cache_oblivious:false, 13.95-14.32 ms with 31 elements), so
it cannot confirm the mechanism and the change rests on the CI data. The
level of ClickHouse#7 stays (31 vs 32 elements: 0.98x); ClickHouse#7/#6 goes from 1.11 to
1.03.

Related: ClickHouse#120510

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Sep 30, 2026
`lowerUTF8`/`upperUTF8` of `mixed_01_clustered` (queries #4/#5) ran at one of
two levels per server process in Performance Comparison, about 1900 minor
page faults and 2 ms of system time apart, which is ~17% of the 12 ms arm
query. That column keeps all its non-ASCII rows in the first block, so it is
the only one whose query takes both result reservations of
`LowerUpperUTF8Impl`: the non-ASCII path rounds up to a power of two, 16 MiB
for a 65536-row block of 128-byte values plus 127 bytes of padding, while the
all-ASCII path reserves exactly 8 MiB + 127 bytes. perf.py purges jemalloc
before every run, so each run touches its pages afresh.

Run the test at the default block size, 65409 rows (`DEFAULT_BLOCK_SIZE`,
65536 minus that padding): a block stays below 8 MiB and both paths get
8 MiB. `mixed_01_block_tail` follows the block size, so its 64 non-ASCII rows
are still the last rows of every full block. Row length, block count, query
order and every case are unchanged.

Local A/A with the official master build and perf.py: the old fixture shows
the split in 33 of 40 server processes, the new one in none, and no query of
the test moved in 12 complete-test repetitions per fixture.

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
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 7, 2026
`perf.py --stop-merges` stops merges after the last fill query. The old fill
wrote ~19 parts per table and background merges started during the fill, so
the stop landed mid-merge: a merge past its cancellation point completed, the
others were cancelled, and each server measured its own layout. In
`Performance Comparison (arm_release, master_head, 2/6)` on ClickHouse#117253 the `pfor`
merge `all_1_6_1` (6.3M rows) finished on the right server 3 ms before the stop
and was cancelled on the left one, so every measured run read 14 parts on the
right and 19 on the left, and the right server (with one 6.3M-row part on the
critical path of the parallel count) was slower: `#4` +37.7%, `#5` +16.4%.

Now both tables stop their merges before the inserts, each insert writes
exactly 20 parts of 1M rows (`numbers()` emits `max_block_size` blocks, the
squashing cuts at `min_insert_block_size_rows`), and the `pfor` table is filled
from the same expression instead of a `SELECT *` copy, whose block boundaries
depend on how the read streams interleave. The `throwIf` checks the insert
layout at the end of the fill; the per-table stop keeps that layout until the
measured runs (the global `SYSTEM START MERGES` before teardown releases it).
Parts keep ~1M rows, so the `pfor` posting lists still span several blocks of
`text_index_posting_list_block_size = 131072`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Nov 16, 2026
filterWithBlanks copied the left key into the right key column of a LEFT JOIN
one row at a time, with a virtual insertFrom or insertDefault per row. It now
reads the filter 64 rows at a time (bytes64MaskToBits64Mask, as in
filterArraysImpl): a chunk whose rows are all kept is one insertRangeFrom, a
chunk whose rows are all blank is one insertManyDefaults, and any other chunk
keeps the per-row loop. ColumnNullable gets an insertManyDefaults override, so
a blank Nullable chunk fills the nested column and the null map in bulk instead
of 64 virtual insertDefault calls.

Measured on x86 release (8 pinned cores; wall = median of 21 runs, user-space
instructions = median of 3 perf stat runs minus startup), base -> this commit:
- join_nullable_keys_small_table #4: 0.61x wall, 0.47x instructions;
  ClickHouse#8: 0.71x / 0.55x; #3: 0.66x / 0.55x; ClickHouse#7: 0.80x / 0.66x.
- Alternating rows and runs of 2, 3 and 100 rows: 0.86x-0.99x instructions.
- Queries of the same test that do not reach filterWithBlanks: within 0.4%
  instructions (wall moves up to +23% between the two builds from code
  placement alone, with the same instruction count).

The added perf query covers the per-row path (alternating matched and
unmatched rows), which the existing queries of the test do not reach.
The test runs all its queries (`run_all_queries`), as it now has more than
the 10 that CI samples.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Nov 16, 2026
The loop moves into a new IColumn::insertFromOrDefaults, which IColumnHelper
implements on the concrete column type, so insertFrom, insertDefault,
insertRangeFrom and insertManyDefaults are no longer virtual calls. Consecutive
64-row chunks that are entirely kept or entirely blank are inserted with one call.

User-space instructions relative to master (x86 release, join_nullable_keys_small_table
and probes with runs of matched rows): #4 0.43x (0.46x with plain 64-row chunks),
UInt64 runs of 1 to 3 rows 0.80x to 0.82x (0.94x to 0.95x), Nullable(UInt64) runs of
1 to 3 rows 0.90x (0.96x); queries that do not reach the function are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
CurtizJ pushed a commit that referenced this pull request Nov 17, 2026
The native ORC reader decoded the boolean run-length streams one value at
a time: `BooleanRleDecoder::next` refilled its byte with a one-byte
`ByteRleDecoder::next` call (and a one-byte `readBytes`/`memcpy` for literal
runs) every 8 values and kept its bit state in members stored through
`char *`. The PRESENT stream of every nullable column goes through it, as
does the DATA stream of `Bool` columns. `ByteRleDecoder::next` with a null
mask (`Nullable(Int8)`, union tags) branched per position and called
`readByte` per value.

Both functions are the hot leaves of `formats_columns_nullable` query ClickHouse#28
(`sum(if(col_int8 IS NULL, 1, 0))` over ORC) and are where the slow
aarch64 builds lose 40% on it in the performance comparison
(`BooleanRleDecoder::next` x1.5-2.7 samples in 9 of 9 slow jobs).

Now the unmasked boolean path decodes whole bytes with one
`ByteRleDecoder::next` call per 1 KiB and expands them with a 256-entry
table, and both masked paths decode the non-null values with the unmasked
path and move them to their rows from the back, like `FloatingColumnReader`.
The stream consumption and the decoder state between calls are unchanged.

x86, RelWithDebInfo, max_threads = 1, 8 interleaved rounds of 20 runs,
mean of paired ratios (95% CI):
- ClickHouse#28 sum(if(col_int8 IS NULL)): 7.60 -> 3.90 ms, -48.8% (-49.7 .. -48.0)
- #4 SELECT *: 368.5 -> 309.9 ms, -16.2%
- ClickHouse#20 avg(col_int32): 8.10 -> 5.75 ms, -29.5%
- ClickHouse#36 groupArray(col_string): -9.2%; ClickHouse#60 toYear(col_datetime): -7.7%
- 10M rows sum(Bool): 16.85 -> 3.85 ms, -77.2%
- 10M rows countIf(Nullable(Bool) IS NULL): 45.95 -> 23.00 ms, -49.9%
ClickHouse#28: 44.6 -> 12.2 instructions per row, 12.3 -> 5.0 cycles per row.

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