# recursive_worktable_factor

> recursive_worktable_factor — Sets the planner's estimate of the average size of a recursive query's working table. Observed in PG15–19 Beta 3; its last measured boot default is 10 in PG19 Beta 3, with user context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Sets the planner's estimate of the average size of a recursive query's working table.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `real` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | — | Raw unit |
| Range | `0.001` – `1e+06` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Query Tuning / Other Planner Options | Upstream classification |
| Latest boot value | `10` | 10 |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG15 |
| Present in | PG15–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`0bd7af082ace`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=0bd7af082ace135581bb13a6bd2d88e68c66a3e0) — Invent recursive_worktable_factor GUC to replace hard-wired constant. |
| Commit date | 2022-03-24 |
| Discussion | [thread 1](https://postgr.es/m/CANbhV-EuaLm4H3g0+BSTYHEGxJj3Kht0R+rJ8vT57Dejnh=_nA@mail.gmail.com) |

## Default history {#default-history}

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

## How it works {#mechanism}

recursive_worktable_factor estimates the average recursive working-table size as a multiple of the non-recursive seed term. The estimate feeds costs for joining the worktable to other relations.

It does not cap recursion, memory, rows, or iterations. A low-fan-out traversal can be modeled with a smaller value, while graph expansion with high fan-out may need a larger estimate.

The value is used during planning; actual recursive growth still depends on data and termination predicates. Misestimation can select an unsuitable join method inside the recursive term. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

## Tuning advice {#tuning-advice}

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

| Workload | Guidance |
| --- | --- |
| OLTP | Keep recursive_worktable_factor at its upstream default unless representative plans show a repeatable, workload-wide problem. Test a local override first and include planning latency as well as execution latency. |
| OLAP | Analytical SQL can make recursive_worktable_factor more visible because joins, cursors, or recursion are larger. Benchmark the full statement family and inspect estimates rather than copying a single successful value. |
| Small nodes | On a small host, avoid increasing planning search or memory pressure through recursive_worktable_factor without a measured benefit. Prefer query-local structure or a scoped role setting over a cluster-wide override. |
{.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: PG15–19 Beta 3 unmodified; OLAP: PG15–19 Beta 3 unmodified; CRIT: PG15–19 Beta 3 unmodified; TINY: PG15–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- Treating recursive_worktable_factor as an executor resource limit rather than a planning assumption or policy.
- Testing only one parameter set or one data distribution.
- Expecting an already cached plan to be rewritten automatically.
- Using a global override to hide stale statistics or fragile SQL structure.

## Related parameters {#related-parameters}

[`work_mem`](/parameters/work-mem/) · [`enable_nestloop`](/parameters/enable-nestloop/) · [`enable_hashjoin`](/parameters/enable-hashjoin/) · [`default_statistics_target`](/parameters/default-statistics-target/)

## References {#references}

- [PostgreSQL 19 Beta 3 — recursive_worktable_factor](https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-RECURSIVE-WORKTABLE-FACTOR)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
