select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / STATISTICS

compute_query_id

Read PG 18 manual ↗

Enables in-core computation of a query identifier.

Type
enum
Context
superuser
Measured default
auto
Unit
Metadata snapshot
18
Allowed values
auto, regress, on, off

Definition PG 18 manual

Enables in-core computation of a query identifier. Query identifiers can be displayed in the pg_stat_activity view, using EXPLAIN, or emitted in the log if configured via the log_line_prefix parameter. The pg_stat_statements extension also requires a query identifier to be computed. Note that an external module can alternatively be used if the in-core query identifier computation method is not acceptable. In this case, in-core computation must be always disabled. Valid values are off (always disabled), on (always enabled), auto, which lets modules such as pg_stat_statements automatically enable it, and regress which has the same effect as auto, except that the query identifier is not shown in the EXPLAIN output in order to facilitate automated regression testing. The default is auto.

Note

To ensure that only one query identifier is calculated and displayed, extensions that calculate query identifiers should throw an error if a query identifier has already been computed.

Measured default history
Version intervalDefault
14 – 19auto
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

compute_query_id controls PostgreSQL's in-core normalized query identifier. The identifier can appear in pg_stat_activity, EXPLAIN, and logs, and is required by pg_stat_statements unless another module computes one.

auto lets a module request in-core computation, on always computes, off prevents it, and regress behaves like auto while suppressing the ID in EXPLAIN for stable regression output.

Only one provider should compute the identifier. An extension with an alternative algorithm must disable the in-core implementation and detect conflicts rather than silently publishing two incompatible IDs. Its superuser context permits an authorized session change without a server restart.

Operational considerations

Enabling the in-core provider while an extension also attempts to compute a different query identifier.

Setting off and silently losing IDs required by pg_stat_statements, logs, or correlation tooling.

Treating regress as a production optimization rather than a test-output mode.

Using query IDs as stable cross-major-version or cryptographic identifiers.

Workload guidance

OLAP: auto or on can make long analytical statements easier to correlate across pg_stat_activity, EXPLAIN, and logs. The cost is query-tree normalization and hashing, not clock reads; compare planning CPU on workloads with very large statements.

OLTP: Use auto when pg_stat_statements or another module should request the in-core identifier, and use on only when logs, EXPLAIN, or monitoring require IDs without such a module. Measure query-normalization overhead at peak parse/plan rates.

SMALL: Keep auto unless an external query-ID provider requires off. regress is for stable regression output, not a smaller production setting, and off can remove IDs required by pg_stat_statements.

Version history 2
  1. PG 14 → 15changed
  2. PG 13 → 14added

Related entries

Further reading

Definition snapshot: english-manuals:4def606c9b53915b1db78471122… · English manual source