docs: document EXPLAIN REPLAN - #38401
Open
claude[bot] wants to merge 1 commit into
Open
Conversation
`EXPLAIN ... FOR REPLAN <VIEW | MATERIALIZED VIEW | INDEX>` has shipped since February 2024 but was never documented. Add a reference page for it, following the layout of the other EXPLAIN pages: a YAML-backed syntax section, a Details section, examples, and a privileges snippet. The page covers what replan mode changes relative to the other two EXPLAIN forms that can report a plan for the same object, the stages each object type accepts, and the optimizer feature overrides that motivate the statement. Every example was executed against a Materialize emulator running v26.38.1 and the output is verbatim. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TLzijB9j98ea1QCkhQA5qJ
ggevay
self-requested a review
August 21, 2026 17:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Pranshu Maheshwari · Slack thread
Before: a reader searching the docs site for
REPLANfound nothing. The SQL commands index listed fiveEXPLAINpages, the RBAC command-privileges appendix listed fiveEXPLAINrows, and the "Explained object" table onEXPLAIN PLANstopped atMATERIALIZED VIEW name. The only trace of the keyword anywhere indoc/userwas the mechanical keyword appendix.After: there is an
EXPLAIN REPLANreference page at/sql/explain-replan, listed alongside its siblings in both index listings, and the "Explained object" table onEXPLAIN PLANhas a row pointing at it.This documents
EXPLAIN [<stage> PLAN ... FOR] REPLAN <VIEW | MATERIALIZED VIEW | INDEX> <name>, which re-runs the optimizer on an existing object instead of printing the plan that is already installed.The page follows the layout of the other
EXPLAINpages: front matter withmenu.main.parent: commands, a one-paragraph lede, the sharedEXPLAINinstability warning,## Syntaxbacked by a newdoc/user/data/examples/explain_replan.ymlviainclude-syntax(the mechanismEXPLAIN TIMESTAMP,EXPLAIN SCHEMA, andEXPLAIN FILTER PUSHDOWNuse),## Details,## Examples, and## Privilegesbacked by a new headless snippet. Output blocks are shown in psql's aligned form, matching the example blocks on the sibling pages. The lede states thatREPLANis an explained object ofEXPLAIN PLANrather than a statement of its own, so the stages, formats, and output modifiers are inherited from that page and are linked rather than duplicated.Motivation
The syntax was introduced in #25026 (merged Feb 2024), whose description introduced it as "new (for now undocumented) syntax".
REPLAN VIEWfollowed in #25586. The omission was therefore deliberate at the time, but explicitly temporary, and it was never revisited: there is no feature flag, no unsafe-mode gate, and no RBAC difference.EXPLAIN ... FOR REPLAN ...is reachable today by any user withUSAGEon the object's schema. This closes that gap.Description
New files:
doc/user/content/sql/explain-replan.md— the reference page.doc/user/data/examples/explain_replan.yml— the syntax block and syntax-element table.doc/user/content/headless/sql-command-privileges/explain-replan.md— the privileges snippet.EXPLAIN REPLANshares thePlan::ExplainPlanRBAC arm, so the requirement is the same asEXPLAIN PLAN:USAGEon the schemas containing the relations in the explainee.Modified files:
doc/user/content/sql/explain-plan.md— one row added to the "Explained object" table.doc/user/data/sql_commands_all.yml— index entry, alphabetically betweenEXPLAIN PLANandEXPLAIN SCHEMA.doc/user/data/rbac/command_privileges.yml— appendix entry in the same position.The non-obvious part worth a reviewer's attention is the stage/object-type support matrix. Every cell below was executed against a live server, not inferred:
REPLAN VIEWREPLAN MATERIALIZED VIEWREPLAN INDEXPHYSICAL PLAN AS TEXT)RAW PLANDECORRELATED PLANLOCALLY OPTIMIZED PLANOPTIMIZED PLANPHYSICAL PLANA view rejects the post-optimization stages, an index rejects the pre-optimization stages, and only a materialized view accepts all of them. Bare
EXPLAIN REPLAN VIEW vfails with "EXPLAIN statement for a view needs an explicit stage", which the page shows.DECORRELATED PLANis included becauseREPLANruns the fullCREATE ...optimizer pipeline, the same pipeline for whichEXPLAIN PLANalready documents that stage under itsCREATE VIEWandCREATE MATERIALIZED VIEWforms.Verification
Docs-only change, no automated tests. Validation run locally:
e7e46f0d1). All plan output in the page is verbatim server output, not hand-edited.ci/test/lint-docs.sh(default config, andconfig.toml,config.skill.tomlfor the markdown-docs build) with hugo v0.152.2+extended. Clean.htmltest -s ci/www/public -c doc/user/.htmltest.yml: passed, 974 documents.bin/format-docsandci/test/lint-main/checks/check-whitespace.sh: clean, no reformatting needed.#supported-stagesand#optimizer-feature-overridesanchors referenced from the YAML, the SQL commands index entry, and the RBAC appendix row.Generated by Claude Code