Skip to content

trace_sort

trace_sort — Emit information about resource usage in sorting. Observed in PG9.0–19 Beta 3; its last measured boot default is off 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: “Emit information about resource usage in sorting.”

Identity

Type , Valuebool
Upstream pg_settings type
Context , Valueuser
Settable by an ordinary user
Unit , Value
Raw unit
Range , Value
Raw limits in the last observed version
Enum values , Value
— for non-enum types
Category , ValueDeveloper Options
Upstream classification
Latest boot value , Valueoff
off

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

Measured PG9.0–19 Beta 3 boot defaults
Versions Raw boot_val Unit Human value
PG9.0–19 Beta 3 off off

How it works

trace_sort emits internal resource-use messages for sort operations, including memory, run generation, merge passes, and timing details useful to PostgreSQL developers.

It is diagnostic logging, not the same as EXPLAIN’s Sort Method output or log_temp_files. Enabling it can produce many messages on sort-heavy workloads.

The switch does not alter work_mem, the sorting algorithm, or spill thresholds. It should be scoped to a reproduction and paired with log-level settings that actually capture the output. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

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 trace_sort. 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 trace_sort’s debug overhead and artifacts. Prefer standard EXPLAIN and statistics first, and isolate any developer experiment from normal users.
Small nodes Keep trace_sort at its upstream default. A small host has less spare CPU, disk, connection, and log capacity for developer instrumentation.

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
Caution

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

  • Leaving trace_sort 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.

work_mem · log_temp_files · enable_sort · temp_file_limit · log_min_messages

References