Explain pretty make default by Fgrtue · Pull Request #105036 · ClickHouse/ClickHouse · GitHub
Skip to content

Explain pretty make default#105036

Merged
Fgrtue merged 85 commits into
masterfrom
explain-pretty-make-default
Jun 28, 2026
Merged

Explain pretty make default#105036
Fgrtue merged 85 commits into
masterfrom
explain-pretty-make-default

Conversation

@Fgrtue

@Fgrtue Fgrtue commented May 15, 2026

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Make EXPLAIN [PLAN] actions=1, compact=1, pretty=1 the default.

Version info

  • Merged into: 26.7.1.194

@clickhouse-gh

clickhouse-gh Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label May 15, 2026
Comment thread src/Core/Settings.cpp Outdated
Comment thread tests/queries/0_stateless/03100_lwu_36_json_skip_indexes.sql Outdated
@rienath rienath self-assigned this May 15, 2026
Fgrtue and others added 2 commits May 15, 2026 15:49
Adds the missing entry to SettingsChangesHistory's 26.5 block so that
`SET compatibility = '25.5'` (or any version older than 26.5) reverts
`query_plan_pretty_default` to its pre-26.5 value `false` via
`applyCompatibilitySetting`.

Without this entry, the test `04219_explain_plan_pretty_default` (test 1
of 5) fails — it asserts that the `compatibility = '25.5'` knob rolls
the new pretty default back. `02995_new_settings_history` was also
failing because it cross-checks that newly declared settings have a
corresponding entry in the history.

CI report: #105036

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
A second batch of stateless tests that the previous opt-out commits
missed. All of these inspect EXPLAIN PLAN / EXPLAIN AST output (either
matching it against a reference file, grepping it for substrings, or
counting lines), and so they break when the default flips to the
compact/pretty/action-annotated form.

The fixes are:

- 14 .sql tests without `-- { echo }`: prepend
  `SET query_plan_pretty_default = 0;` (placed after any leading Tags
  block, so `getTestTagsLength` still strips it).

- 3 .sh tests (`02303_query_kind`, `04093_lazy_final_combined_filtering`,
  `04095_lazy_final_with_lazy_materialization`): append
  `--query_plan_pretty_default=0` to `$CLICKHOUSE_CLIENT`
  (and `$CLICKHOUSE_LOCAL` in `02303_query_kind`, which also calls
  `clickhouse-local`).

- `03280_aliases_for_selects_and_views`: move the SET line below the
  two `EXPLAIN AST ... -- { clientError SYNTAX_ERROR }` queries.
  Placing it above breaks `TestHint` detection of the expected client
  error, the same regression that commit fdcb993 on master already
  fixed for `SET enable_analyzer`.

Known still-failing: tests with `-- { echo }` / `-- { echoOn }` where
the SET on line 1 displaces `-- Tags:` from the first line — so
`getTestTagsLength` no longer strips the Tags block and those lines
end up echoed before the rest of the test. Fixing those needs the
reference files to be regenerated locally, so they're left for a
follow-up commit.

CI report: #105036

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

@rienath rienath left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. I've left some comments. Let's also mention the new query_plan_pretty_default setting in the changelog

Comment thread docs/en/sql-reference/statements/explain.md Outdated
Comment thread docs/en/sql-reference/statements/explain.md Outdated
Comment thread tests/queries/0_stateless/04219_explain_plan_pretty_default.sql Outdated
Comment thread tests/queries/0_stateless/03100_lwu_36_json_skip_indexes.sql Outdated
Comment thread src/Interpreters/InterpreterExplainQuery.cpp Outdated
Comment thread src/Interpreters/InterpreterExplainQuery.cpp Outdated
@Fgrtue Fgrtue marked this pull request as draft May 15, 2026 16:02
Comment thread tests/queries/0_stateless/00944_minmax_nan.sql Outdated
Comment thread tests/integration/test_storage_iceberg_with_spark/test_explanation.py Outdated
Comment thread tests/queries/0_stateless/00183_prewhere_conditions_order.sql Outdated
Comment thread docs/en/sql-reference/statements/explain.md Outdated
Comment thread tests/queries/0_stateless/01591_window_functions.sql Outdated
Comment thread tests/queries/0_stateless/04219_explain_plan_pretty_default.reference Outdated
Comment thread tests/queries/0_stateless/02354_vector_search_queries.sql Outdated
@clickhouse-gh

clickhouse-gh Bot commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 38 queries analysed

This PR only makes the pretty/compact/actions form the default for EXPLAIN PLAN output (settings, interpreter formatting, docs, and test pins) and leaves the query-execution hot path untouched. The two flagged ClickBench improvements (Q4 -17.4%, Q15 -16.8%) are plain SELECTs that never exercise EXPLAIN, so the PR cannot plausibly speed them up; both deltas are consistent-looking run-to-run variance and have been downgraded to not-sure. No real performance change is expected from this change.

clickbench

⚠️ 2 inconclusive

Flagged queries (2 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 4 not_sure 264 218 -17.4% <0.0001 PR only changes EXPLAIN PLAN default output format; Q4 SELECT never runs that path — off-path, run-to-run variance
⚠️ 15 not_sure 250 208 -16.8% <0.0001 PR only changes EXPLAIN PLAN default output format; Q15 SELECT never runs that path — off-path, run-to-run variance

q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 4ffe6b1c-a11e-4e08-a4b2-bb964cd1265b
  • MIRAI run: 80840cb2-a6d0-4680-ae8f-4f0b72131a6b
  • PR check IDs:
    • clickbench_296512_1782640827
    • clickbench_296519_1782640827
    • clickbench_296528_1782640827
    • tpch_adapted_1_official_296537_1782640827
    • tpch_adapted_1_official_296553_1782640827
    • tpch_adapted_1_official_296563_1782640827

@Fgrtue Fgrtue added this pull request to the merge queue Jun 28, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 28, 2026
@Fgrtue Fgrtue added this pull request to the merge queue Jun 28, 2026
@Fgrtue Fgrtue removed this pull request from the merge queue due to a manual request Jun 28, 2026
@Fgrtue Fgrtue enabled auto-merge June 28, 2026 00:55
Comment thread src/Core/SettingsChangesHistory.cpp Outdated
@clickhouse-gh

clickhouse-gh Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.30% 85.30% +0.00%
Functions 92.60% 92.60% +0.00%
Branches 77.50% 77.50% +0.00%

Changed lines: Changed C/C++ lines covered by tests: 46/47 (97.87%) | Lost baseline coverage: none · Uncovered code

Full report · Diff report

@Fgrtue Fgrtue added this pull request to the merge queue Jun 28, 2026
Merged via the queue into master with commit b240acb Jun 28, 2026
166 of 169 checks passed
@Fgrtue Fgrtue deleted the explain-pretty-make-default branch June 28, 2026 12:05
@Fgrtue

Fgrtue commented Jun 28, 2026

Copy link
Copy Markdown
Contributor Author

@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 28, 2026
alexey-milovidov added a commit to zex-hyd/ClickHouse that referenced this pull request Jul 3, 2026
…lan_default` default flip

This test failed on CI (result differs with reference) for two independent
reasons on the current head:

1. The `.sql` printed the label `-- Additional WHERE clauses present, 2 full
   parts selected by partition key / 1 part partially selected by PK` while the
   `.reference` expected the same line suffixed with `, expect index usage`. The
   query below it now uses the vector index under partial primary key pruning
   (the point of this PR), so `USearchSearchCount` is `1` and the label should
   read `expect index usage`. Align the `.sql` literal with the `.reference`.

2. `ClickHouse#105036` made `explain_query_plan_default = 'pretty'` the default on master,
   which renders `EXPLAIN` plans with box-drawing characters that `trimLeft` does
   not strip, so the grepped `Description:`/`Granules:` lines no longer match the
   plain reference. Master added `SET explain_query_plan_default = 'legacy';` to
   this test for exactly this reason; do the same here.

Verified end-to-end against the PR build (26.7.1.1): the test now matches its
reference.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104754&sha=9d1b3aec2a86952d71263172400a8a97bcb05c0f&name_0=PR

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
alexey-milovidov added a commit that referenced this pull request Jul 3, 2026
The recent master merge brought in `explain_query_plan_default = 'pretty'`
(the new default since 26.7, introduced in #105036), which changes the
default `EXPLAIN PLAN` output format. The five constant-folding tests that
assert on `EXPLAIN indexes = 1` output started failing in Fast test with
"result differs with reference":
`04218_partition_pk_pruning_constants_folding`,
`04219_partition_minmax_skip_index_constants_folding`,
`04220_partition_id_constants_folding`,
`04221_partition_id_with_minmax_constants_folding`,
`04314_partition_constants_folding_derived_key`.

Add `SET explain_query_plan_default = 'legacy';` to each of them so their
existing (already reviewed) references stay valid. This mirrors how #105036
handled the ~414 existing `EXPLAIN` tests when it changed the default, and
keeps the references demonstrating per-part constant folding unchanged.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104582&sha=ebf528aa38a90f8bc69735ead2da02540b2d479b&name_0=PR&name_1=Fast%20test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
UnamedRus added a commit to UnamedRus/ClickHouse that referenced this pull request Jul 3, 2026
`EXPLAIN` output became pretty by default on master (ClickHouse#105036,
`explain-pretty-make-default`). In pretty mode `JoinStep` prints the
join clauses under a `Join conditions` node instead of the flat
`Clauses:` line, so the test's `WHERE explain ILIKE '%Clauses%'` filter
matched nothing and the reference no longer applied.

That master change updated the references of existing tests, but could
not touch 04326 because the test only exists on this branch. Add an
explicit `pretty = 0` to every `EXPLAIN actions = 1` so the flat
`Clauses:` format (and the committed reference) stay valid regardless of
the server default.

Related: ClickHouse#106955

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants