Repository navigation
Conversation
There was a problem hiding this comment.
I have an alternative idea for min-max optimization: we could add a part-level min-max per skip index and load it into memory, similar to how we handle partition columns. This approach would be cost-effective and only adds a small overhead per skip index. @alexey-milovidov WDYT?
Currently, I’m using partition by indexHint(a, b, c...) to build this kind of min-max part index.
9ab9279 to
23ac69c
Compare
|
Workflow [PR], commit [b5305cd] Summary: ❌
|
c7797ca to
4288c15
Compare
|
@zoomxi Thanks but this needs a lot more code comments and a description of the logic in the PR message, please. If I remember correctly, parts already store a min/max value per column. This information can be utilized for aggregate functions
"part-level min-max per skip index" ... it's not really clear to me how that would work. A min-max index stores min/max information already per index granule, why would it store it again per part (which is of coarser granularity)? |
|
@nickitat Like to take a look at this PR? |
@rschu1ze The idea is to promote skip-index min-max to part-level metadata (kept in memory) to enable pruning entire parts without the IO overhead of reading .skp files, effectively giving arbitrary columns the same "early-filtering" benefits as partition keys. (Reference: #65413 and #64210) |
@rschu1ze |
|
However, as @amosbird suggested, would it be better to aggregate skip index data to part-level and keep it in memory (like |
|
Thanks, I read #65413 and I liked it. I actually think that storing min/max metadata has such a small storage overhead that we could do it implicitly for all parts (i.e. without the user creating requesting it explicitly via PS: Note that there is some overlap with settings |
d070b68 to
18f108e
Compare
18f108e to
f60d233
Compare
|
Sorry, I missed all notifications from this PR somehow. Will try to catch up today. |
Thanks, I've submitted #93318 to implement part-level aggregation for minmax skip index as discussed here. For minmax, once #93318 is merged, this PR should be updated to use part-level aggregated data first, with the current granule-level approach as fallback. For set, as set indexes may be unsuitable for part-level aggregation, this PR remains the primary approach. So perhaps #93318 should be reviewed first, then this PR can be updated accordingly. |
| DECLARE(Bool, optimize_use_implicit_projections, true, R"( | ||
| Automatically choose implicit projections to perform SELECT query | ||
| )", 0) \ | ||
| DECLARE(Bool, optimize_use_skip_index_aggregation, true, R"( |
There was a problem hiding this comment.
This introduces a new query-execution optimization path (serving min/max/uniq* from skip indexes / per-part statistics) and enables it by default via optimize_use_skip_index_aggregation = true.
Given the correctness risk profile of a new optimizer execution strategy, this should be guarded behind an explicit experimental gate first (for example allow_experimental_* or a disabled-by-default setting), then enabled by default only after bake time.
There was a problem hiding this comment.
This is still live in the current code: optimize_use_skip_index_aggregation is declared with default true in Settings.cpp, and there is no separate allow_experimental_* gate around the new planner path.
Given this adds new execution paths that answer min/max/uniq* from skip-index / statistics metadata, I still think rollout should be opt-in first (experimental gate, or default false until bake time).
There was a problem hiding this comment.
This concern is still live in the current head.
optimize_use_skip_index_aggregation is still declared with default true in src/Core/Settings.cpp, and the new planner paths in optimizeUseAggregateProjection still apply skip-index / column-statistics aggregate answering without a separate allow_experimental_* guard.
Because this adds new execution paths for min/max/uniq* that can change correctness if any edge case is missed, please gate it behind an experimental setting (or keep the optimization setting default false until GA-level hardening is complete).
The stress-test log scanner (`ci/jobs/scripts/log_parser.py`) uses `rg --text -A 10 -o 'Logical error.*'` against the server log. Test `04208_iceberg_disk_with_cache_no_bad_cast.sql` previously included the literal exception string in its SQL comments. When such a query fails (it is expected to fail at table-resolution time), the full query — including those comments — is echoed into the `<Error> executeQuery` log entry. If a later, completely unrelated fatal error occurs in the same stress-test run, the scanner picks up the SQL-comment occurrence first and uses it as the failure name, even though the actual stack trace (and `STID`) belong to a different bug. Three master/PR runs on 2026-05-07 hit this false positive: - `Stress test (experimental, serverfuzz, arm_tsan)` on master (commit 69167ef) — actual abort was a `chassert(false)` in `paranoidCheckForCoveredPartsInZooKeeperOnStart`, reported as `STID 2508-5dc3`. - `Stress test (arm_asan_ubsan)` on PR ClickHouse#100377 — actual abort was `Not-ready Set is passed as the second argument for function 'in'` in `FunctionIn::executeImpl`, reported as `STID 0250-4e52`. - `Stress test (amd_msan)` on PR ClickHouse#93037 — same `Not-ready Set` family, reported as `STID 0250-41a5`. The original `Bad cast from CachedObjectStorage to S3ObjectStorage` bug that this test guards against is genuinely fixed by ClickHouse#104258 — the unwrap loop in `S3StorageParsedArguments::fromDisk` is in place and none of these three runs actually crashed in that code path. This commit reworks the comments in 04208 so they describe the bug without containing the verbatim `Logical error: '...'` pattern that the scanner greps for, and adds a `NOTE` explaining why the verbatim text is intentionally avoided. The SQL queries and expected `serverError` codes are unchanged. CI report (master arm_tsan): https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=69167ef25d21358fd8f171e593849ea73195dd1b&name_0=MasterCI&name_1=Stress%20test%20%28experimental%2C%20serverfuzz%2C%20arm_tsan%29 Co-Authored-By: Claude Opus 4.7 <[email protected]>
LLVM Coverage Report
Changed lines: 91.59% (610/666) | lost baseline coverage: 6 line(s) · Uncovered code |
|
Dear @nickitat, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
Dear @nickitat, you haven't been active on this PR for 30 days. You will be unassigned. Will you continue working on it? If so, please feel free to reassign yourself. |
|
@copilot resolve the merge conflicts in this pull request |
Sorry for the late reply. To make it easier to review and merge, I extracted the part for " |
Resolve the conflict with the move of the settings changes history into the setting declarations (ee6b44f): the history records this PR added to `SettingsChangesHistory.cpp` now live as trailing arguments of the `DECLARE` of each setting. - retargeted PR record [email protected] to 26.10 (settings-history check rule) Also resolved conflicts in: - `src/Processors/QueryPlan/Optimizations/optimizeUseAggregateProjection.cpp` - `src/Storages/MergeTree/MergeTreeData.cpp` - `src/Storages/MergeTree/MergeTreeData.h` `preparePartsPruning` follows master's `ConditionTemplate` min/max condition; the skip-index and column-statistics candidates run only when master's statistics-based min/max path does not apply. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Optimize min/max/uniq aggregate functions by reading from skip indices instead of scanning data. Closes #92758.
Workflow [PR]
Sync PR [sync-upstream/pr/93037]