# debug_discard_caches

> debug_discard_caches — Aggressively flush system caches for debugging purposes. Observed in PG14–19 Beta 3; its last measured boot default is 0 in PG19 Beta 3, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Aggressively flush system caches for debugging purposes.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | — | Raw unit |
| Range | `0` – `0` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Developer Options | Upstream classification |
| Latest boot value | `0` | 0 |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG14 |
| Present in | PG14–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`6201fa3c166f`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=6201fa3c166fe2383dd44a9dd5082bc748c2937a) — Rename debug_invalidate_system_caches_always to debug_discard_caches. |
| Commit date | 2021-07-13 |
| Discussion | [thread 1](https://postgr.es/m/1374320.1625430433@sss.pgh.pa.us) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG14–19 Beta 3 | `0` | — | 0 |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

debug_discard_caches invalidates system-catalog cache entries at the earliest opportunity; higher values recurse the behavior. Nonzero values make the server extremely slow to expose cache invalidation bugs.

It is supported only in builds compiled with DISCARD_CACHES_ENABLED, automatically associated with --enable-cassert. Production builds keep zero and reject attempts to change it.

The parameter tests correctness under pathological cache churn. It does not flush shared_buffers, the operating-system page cache, or ordinary query result caches. Its superuser context permits an authorized session change without a server restart.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Do not tune production OLTP with debug_discard_caches. Enable it only for a bounded reproduction with an owner, log/disk budget, rollback condition, and evidence-capture plan; restore the default immediately afterward. |
| OLAP | Long analytical runs can amplify debug_discard_caches's debug overhead and artifacts. Prefer standard EXPLAIN and statistics first, and isolate any developer experiment from normal users. |
| Small nodes | Keep debug_discard_caches at its upstream default. A small host has less spare CPU, disk, connection, and log capacity for developer instrumentation. |
{.full-width}

## Pigsty {#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 | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG14–19 Beta 3 unmodified; OLAP: PG14–19 Beta 3 unmodified; CRIT: PG14–19 Beta 3 unmodified; TINY: PG14–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Leaving debug_discard_caches enabled after the bounded diagnostic or recovery task.
- Running the experiment on the only copy of production data.
- Underestimating log, core-file, temporary-file, WAL, CPU, or connection-slot amplification.
- Treating a server that merely starts or completes a query as proof that data and behavior are correct.

## Related parameters {#related-parameters}

[`ignore_system_indexes`](/parameters/ignore-system-indexes/) · [`shared_buffers`](/parameters/shared-buffers/) · [`debug_parallel_query`](/parameters/debug-parallel-query/) · [`allow_system_table_mods`](/parameters/allow-system-table-mods/)

## References {#references}

- [PostgreSQL 19 Beta 3 — debug_discard_caches](https://www.postgresql.org/docs/19/runtime-config-developer.html#GUC-DEBUG-DISCARD-CACHES)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
