debug_print_rewritten
Fact — official short description: “Logs each query’s rewritten parse tree.”
Identity
Lifecycle
| Fact | Value |
|---|---|
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |
Default history
| Versions | Raw boot_val |
Unit | Human value |
|---|---|---|---|
| PG9.0–19 Beta 3 | off |
— | off |
How it works
debug_print_rewritten logs each query’s rewritten parse tree. It exposes the query tree after rule rewriting, which is useful for diagnosing views and rules but can generate very large logs.
debug_print_rewritten is a USER-context setting. An authorized role can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.
The debug_print_* switches feed the normal server logging path, so log_min_messages, log_destination, and collector capacity determine whether the output is retained safely.
Tuning advice
Advice. These are workload-specific starting points and must be validated with measurements.
| Workload | Guidance |
|---|---|
| OLTP | Do not tune or enable debug_print_rewritten globally in production. If server-developer diagnostics require it, isolate one session, bound its duration, and route the resulting logs safely. |
| OLAP | Do not use debug_print_rewritten as a substitute for EXPLAIN on analytical SQL; capture a targeted plan instead of dumping every internal tree. |
| Small nodes | Leave debug_print_rewritten at its normal default. Verbose internal trees can exhaust a small node’s log I/O and disk unexpectedly. |
Pigsty
Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.
| Template | Effective value | Versus upstream boot | Source expression |
|---|---|---|---|
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
Advice — pending human review. Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 unmodified; OLAP: PG9.0–19 Beta 3 unmodified; CRIT: PG9.0–19 Beta 3 unmodified; TINY: PG9.0–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.
Common pitfalls
- Changing debug_print_rewritten in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.
- Leaving an internal-tree dump enabled globally and overwhelming log I/O, storage, or ingestion.
- Treating debug output as a stable public format or as a substitute for targeted EXPLAIN diagnostics.
- Changing debug_print_rewritten globally without a rollback plan and a client or operational compatibility test.
Related parameters
debug_pretty_print · debug_print_parse · debug_print_plan · log_min_messages · client_min_messages