Configuration parameter

recursive_worktable_factor — PostgreSQL configuration parameter

Category Query Planning Default 10

Sets the planner’s estimate of the average size of the working table of a recursive query, as a multiple of the estimated size of the initial non-recursive term of the query.

At a glance

Property Value
Parameter recursive_worktable_factor
Category Query Planning
Default 10.0
Value type floating point
Change scope Per-session (SET)
Available in PostgreSQL 15, 16, 17, 18, 19 (added in 15)

What it does

Sets the planner’s estimate of the average size of the working table of a recursive query, as a multiple of the estimated size of the initial non-recursive term of the query. This helps the planner choose the most appropriate method for joining the working table to the query’s other tables. The default value is 10.0. A smaller value such as 1.0 can be helpful when the recursion has low “fan-out” from one step to the next, as for example in shortest-path queries. Graph analytics queries may benefit from larger-than-default values.

(Description quoted from the official PostgreSQL documentation.)

How to apply a change

Can be set per session with SET, per role/database with ALTER ROLE/DATABASE ... SET, or globally in postgresql.conf.

Inspect the current value and source with SHOW recursive_worktable_factor; or SELECT name, setting, unit, context, source FROM pg_settings WHERE name = 'recursive_worktable_factor';.

Tuning guidance

Raise it when recursive CTEs badly mis-estimate the working-table size and produce poor join orders; most workloads never need to touch it.

Reference

PostgreSQL documentation — recursive_worktable_factor.

Keep going

Related & next steps

Concepts on this page

Was this helpful?

← All configuration parameters