Repository navigation
Conversation
b29f1bc to
82663aa
Compare
|
Workflow [PR], commit [4dc932c] Summary: ✅
AI ReviewSummaryThis PR adds planner-derived Findings
Final VerdictNot ready to merge yet: the new optimization still has an uncovered default-path gap after join-order rewriting. LLVM Coverage ReportMeasured on commit 4dc932c.
Changed lines: Changed C/C++ lines covered: 318/333 (95.50%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes918 object files changed (+662.74 KiB total), 3 added.
716 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units2122 translation units recompiled, 12440 s compile time in total, 2119 of them have a recent master baseline. Translation units without a recent master baseline:
|
… instead of replacing them with constant true.
| {trySplitFilter, "splitFilter", &QueryPlanOptimizationSettings::split_filter}, | ||
| {tryMergeExpressions, "mergeExpressions", &QueryPlanOptimizationSettings::merge_expressions}, | ||
| {tryMergeFilters, "mergeFilters", &QueryPlanOptimizationSettings::merge_filters}, | ||
| {tryDeriveNotNullFiltersFromJoin, "deriveNotNullFiltersFromJoin", &QueryPlanOptimizationSettings::derive_not_null_filters_from_joins}, |
There was a problem hiding this comment.
tryDeriveNotNullFiltersFromJoin only runs in the first pass, before optimizeJoinLogical reconstructs reordered join trees in the second pass. That later rewriter can move null-rejecting edges into join_operator.residual_filter for outer join steps (joinOrderGreedy.cpp:95-102, joinOrderDPSub.cpp:466-477) or create a new outer-under-inner nesting that was not present in the original tree. After that point neither this pass nor resolvePlannerOnlyFilters runs again, so those reordered plans never get the derived IS NOT NULL markers and the outer-to-inner / selective scan-filter optimization is silently skipped.
All new focused tests pin query_plan_optimize_join_order_limit = 0, so this path is not covered today. Can we rerun the derivation after join-order optimization (or have join-order synthesize the markers for residual_filter) and add a join-order-enabled regression case?
There was a problem hiding this comment.
The existing tryConvertOuterJoinToInnerJoin also only runs during the first pass anyway so we can keep it like this for now. We can experiment adding it after the reorder in a follow-up.
9ce67d6
|
@m-selmi @fkastrati — title/description suggestions: Description (currently
Ignore if intentional. |
|
@m-selmi @fkastrati — ClickGap found the following in this PR:
Close anything that's wrong or already addressed. |
|
Reverting. Please reintroduce |
…L filter resolvePlannerOnlyFilters rebuilds a FilterStep with remove_filter = true, using a surviving conjunct's result_name as the filter column name. Because collectFilterConjuncts unwraps aliases, that conjunct can be a column of the step's own output header: filter push-down wraps a pushed predicate in a __filter<name> alias so the removal cannot hit the same-named stream column (ActionsDAG.cpp:3768-3779), and the unwrap discards that protection. checkAndRemoveFilterColumn then erases the column, shrinking the step's output header. The pass replaces node.step outright, so no updateInputHeader reaches the parent JoinStepLogical, whose expression DAG still holds an input node for the erased column, and that node cannot be pruned because the column is also one of the join's outputs. chooseJoinOrder is the first consumer to notice: JoinExpressionActions requires the DAG's input count to equal the left plus right header widths, and aborts with "Input nodes size mismatch in dag". With the join reorder disabled the same inconsistent plan reaches execution and throws NOT_FOUND_COLUMN_IN_BLOCK instead, and a NATURAL JOIN variant, where both sides carry a column of that name, throws UNKNOWN_IDENTIFIER. Re-establish the alias at the rebuild site when the chosen filter node's name collides with the step's output header, which is the same operation, for the same reason, as the push-down site. A Nullable join key is needed to reproduce: it makes the join condition null-rejecting, which is what makes deriveNotNullFiltersFromJoin emit the planner-only marker. Related: #114817 Co-Authored-By: Claude Opus 5 <[email protected]>
Edited by hand following .claude/skills/edit-changelog/SKILL.md, consolidating the nine raw blocks generated between 2026-09-06 and 2026-09-13. The NightlyChangelog job rejected its own edits every night in that period: the verifier did not know that #116566 (reverted by #116586) had itself reverted #109710, so it demanded that no trace of #116586 remain while the rules put its link on the CatBoost entry. Fixed in the job by #119866; this edit passes the patched verifier, and the trailers below give the ledger the missing chain. Failed runs: https://github.com/ClickHouse/ClickHouse/actions/runs/34006912773 through https://github.com/ClickHouse/ClickHouse/actions/runs/34668133756 Changelog-revert: 116566 109710 Revert "Remove CatBoost integration" Changelog-revert: 116586 116566 Revert "Revert "Remove CatBoost integration"" Changelog-revert: 117629 117295 Revert "Skip Darwin fast test in PRs unless labeled ci-macos" Changelog-revert: 118525 118218 Revert "Do not wait for the remote drain when cancelling a remote query" Changelog-revert: 119043 117866 Revert "Add `ci-coverage` label to force LLVM coverage jobs on tests-only PRs" Changelog-revert: 119269 118239 Revert "Require agents to run the style check locally before pushing" Changelog-revert: 119270 115343 Revert "Resume a NATS JetStream subscription after a reconnect" Changelog-revert: 119274 118919 Revert "Carry the mutation version onto a rewritten lightweight `DELETE`" Changelog-revert: 119275 114817 Revert "Convert OUTER join to INNER join by null-rejecting join conditions" Changelog-revert: 119276 110939 Revert "Support real hard links for plain_rewritable metadata." Changelog-revert: 119279 117449 Revert "Print file offsets in the bare fatal stack traces and build the release binary as PIE" Changelog-revert: 119281 116629 Revert "Check access rights in the TimeSeries table functions" Changelog-revert: 119298 118606 Revert "Proper partition pruning with dates" Changelog-revert: 119323 117768 Revert "Docs: Skip private sync for documentation-only pull requests" Changelog-revert: 119334 117356 Revert "Unify the spill trigger for hash joins" Changelog-revert: 119429 114562 Revert "Fix NO_SUCH_COLUMN_IN_TABLE naming a column absent from the table when a part's columns were all renamed or all dropped" Changelog-deleted-entry: 110939 [New Feature] [raw] * Disks with the `plain_rewritable` metadata (`s3_plain_rewritable`, and `azure`/`local` object storages with `metadata_type = plain_rewritable`) support hard links if configured with the new `enable_hard_links` setting, which enables `ALTER` operations and mutations on `MergeTree` tables stored on them. Mutations and partition operations share the unchanged blobs between parts instead of copying them. The setting is off by default, because a disk that has hard links cannot be read by older servers. [#110939](#110939) ([yanglongwei](https://github.com/ylw510)). Changelog-deleted-entry: 114562 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed `NO_SUCH_COLUMN_IN_TABLE` naming a column that is not in the table, when reading or merging a part whose columns had all been renamed or all dropped by a mutation that was not applied yet. The merge kept being retried, so the table stopped compacting. Also fixed the columns of a `MergeTree` part produced by such a merge reading as their default values until the mutation was applied. [#114562](#114562) ([Shaohua Wang](https://github.com/tiandiwonder)). Changelog-deleted-entry: 114817 [Performance Improvement] [raw] * Convert `OUTER JOIN` to `INNER JOIN` when a later JOIN condition filters out its NULL-extended rows, and filter NULL join keys directly at the table scan when column statistics show it is selective. Only conditions of the form `expr1` OP `expr2` are considered, where OP is one of `=`, `<`, `<=`, `>`, `>=`. Each side can be a column or an expression that propagates NULLs. Controlled by the new settings `query_plan_derive_not_null_filters_from_joins` (enabled by default), `query_plan_allow_derived_not_null_filters_execution` (enabled by default) and `query_plan_max_selectivity_for_not_null_filters_execution` (0.7 by default). [#114817](#114817) ([Hechem Selmi](https://github.com/m-selmi)). Changelog-deleted-entry: 115343 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed a `NATS` engine table reading from a JetStream stream (`nats_stream`) silently stopping to consume messages after the NATS server restarted or the connection was re-established. [#115343](#115343) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Changelog-deleted-entry: 116629 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * The table functions reading a `TimeSeries` table (`timeSeriesSamples`, `timeSeriesTags`, `timeSeriesMetrics`, `timeSeriesSelector`, `prometheusQuery`, `prometheusQueryRange`) checked no privilege on it: a user holding only `CREATE TEMPORARY TABLE` could read its target tables' column definitions and rows, and write into them. Each now requires the corresponding privilege on the `TimeSeries` table and on the target table, following an `Alias` target through to the table it points at. `timeSeriesSamples`, `timeSeriesTags` and `timeSeriesMetrics` check the target at table level, since they return it whole and cannot restrict the columns, so a column-scoped grant on the target is not enough; the other three run ordinary target queries, which the planner still checks per column. An external target is authorized before it is looked up, so its existence is not disclosed either. A read fails with `ACCESS_DENIED` when the user's effective `SELECT` row-policy filter on the `TimeSeries` table is not always true, since such a policy cannot be enforced on the target's rows, and the three target functions can no longer back a `CREATE TABLE ... AS` (`BAD_ARGUMENTS`). PromQL over the Prometheus HTTP and remote-read endpoints reaches `timeSeriesSelector` whenever it selects series, so those requests now need these privileges for the user the endpoint authenticated. [#116629](#116629) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 117356 [Backward Incompatible Change] [raw] * `max_bytes_before_external_join` and `max_bytes_ratio_before_external_join` are now the spill threshold for every hash-based `join_algorithm`, including `grace_hash`, which previously ignored them and spilled on `max_rows_in_join` / `max_bytes_in_join` instead. Those two are a hard cap again for every algorithm: they no longer cause spilling, and a join that spills no longer exceeds them. All join algorithms remain available; `join_algorithm = 'grace_hash'` now needs a non-zero spill threshold, and is skipped in favour of the next algorithm in the list when it has none. Set `legacy_join_size_limits_trigger_spilling = 1` (or `compatibility` to 26.8 or older) to restore the previous behavior. [#117356](#117356) ([Yarik Briukhovetskyi](https://github.com/yariks5s)). Changelog-deleted-entry: 117449 [Build/Testing/Packaging Improvement] [raw] * ClickHouse is now built as a position independent executable on Linux amd64 and aarch64 with glibc, including the release builds, so the text segment is subject to ASLR. Addresses in the bare stack trace of a fatal log are now file offsets relative to the object that contains them, annotated with that object for frames outside the main executable, so they can be resolved with `addr2line -e <object> <hex>` regardless of where the binary was loaded. For the same reason `system.errors.last_error_trace`, `system.error_log.last_error_trace` and `system.crash_log.trace` now store a frame of the main executable as its file offset, keeping runtime addresses for frames in other objects. [#117449](#117449) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 117768 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Not applicable. [#117768](#117768) ([Dominic Tran](https://github.com/dhtclk)). Changelog-deleted-entry: 118218 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed cancelling a distributed, `s3Cluster` or parallel-replicas `SELECT` taking up to `receive_timeout` (300 s by default) to take effect, and never reaching some of the remote sources, when one of them was draining the packets left over after a `LIMIT` was satisfied. [#118218](#118218) ([Groene AI](https://github.com/groeneai)). Changelog-deleted-entry: 118239 [NOT FOR CHANGELOG / INSIGNIFICANT] [raw] * Require agents to run the style check locally before pushing. [#118239](#118239) ([Nikita Fomichev](https://github.com/fm4v)). Changelog-deleted-entry: 118606 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Proper partition pruning with dates. Closes [#103433](#103433). [#118606](#118606) ([Konstantin Vedernikov](https://github.com/scanhex12)). Changelog-deleted-entry: 118919 [Bug Fix (user-visible misbehavior in an official stable release)] [raw] * Fixed a pending lightweight `DELETE` read with `apply_mutations_on_fly = 1` evaluating its predicate over patch parts created after it, which made rows disappear from the result and reappear after the mutation materialized. [#118919](#118919) ([Alexey Milovidov](https://github.com/alexey-milovidov)).
Edited following .claude/skills/edit-changelog/SKILL.md. Manual catch-up run of the NightlyChangelog edit step, verified with `verify_edit` of `ci/jobs/changelog_nightly.py`. Changelog-revert: 119284 119279 Revert "Revert "Print file offsets in the bare fatal stack traces and build the release binary as PIE"" Changelog-revert: 120118 117137 Revert "Fix wrong results for `plus`/`minus` keys with a non-integer operand" Changelog-revert: 120119 119305 Revert "Convert `OUTER` join to `INNER` join by null-rejecting join conditions" again Changelog-deleted-entry: 114817 [Performance Improvement] [section] * Convert `OUTER JOIN` to `INNER JOIN` when a later `JOIN` condition filters out its `NULL`-extended rows, and filter `NULL` join keys directly at the table scan when column statistics show it is selective. Only conditions of the form `expr1` OP `expr2` are considered, where OP is one of `=`, `<`, `<=`, `>`, `>=`. Each side can be a column or an expression that propagates `NULL`s. Controlled by the new settings `query_plan_derive_not_null_filters_from_joins` (enabled by default), `query_plan_allow_derived_not_null_filters_execution` (enabled by default) and `query_plan_max_selectivity_for_not_null_filters_execution` (0.7 by default). [#114817](#114817) ([Hechem Selmi](https://github.com/m-selmi)). [#119305](#119305) ([Alexey Milovidov](https://github.com/alexey-milovidov)). Changelog-deleted-entry: 117137 [Bug Fix (user-visible misbehavior in an official stable release)] [section] * Fix wrong results when a `GROUP BY`, `DISTINCT`, `LIMIT BY` or window `PARTITION BY` key was `plus` or `minus` of a partition column with a non-integer constant, for example `x + 1.0` on `Float64` or `d + INTERVAL 1 MONTH` on `Date`. Such a key was assumed injective, so each table partition was evaluated independently without the cross-partition merge; where the key collapses distinct values onto one (float rounding, end-of-month arithmetic, a DST transition) the query returned one row or window frame per partition instead of one per group. Affects the default-enabled `allow_aggregate_partitions_independently`, `allow_distinct_partitions_independently`, `allow_limit_by_partitions_independently`, `allow_creating_set_partitions_independently`, `allow_window_partitions_independently` and `optimize_distributed_group_by_sharding_key`. [#117137](#117137) ([Groene AI](https://github.com/groeneai)). Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Antalya 26.8 - Backport of ClickHouse#114817 - Use partition statistics from manifest list for pruning- ClickHouse#115817
Closes #112456
Outer join to inner join conversion works by looking if a filter above the join rejects default values, NULLs in the case of nullable columns.
This change allows join conditions of enclosing joins to be used for rejecting NULLs too:
deriveNotNullFiltersFromJoinderivescol IS NOT NULLfilters from join conditions and adds them to the plan. Only conditions of the formexpr1OPexpr2are considered, where OP is one of=,<,<=,>,>=.resolvePlannerOnlyFilterseither promote or removes planner derived filters to executable filters based on their estimated selectivity.Performance result:
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Convert
OUTER JOINtoINNER JOINwhen a later JOIN condition filters out its NULL-extended rows, and filter NULL join keys directly at the table scan when column statistics show it is selective. Only conditions of the formexpr1OPexpr2are considered, where OP is one of=,<,<=,>,>=. Each side can be a column or an expression that propagates NULLs. Controlled by the new settingsquery_plan_derive_not_null_filters_from_joins(enabled by default),query_plan_allow_derived_not_null_filters_execution(enabled by default) andquery_plan_max_selectivity_for_not_null_filters_execution(0.7 by default).Workflow [PR]
Sync PR [sync-upstream/pr/114817]