select open change scope Open full search

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

CONFIGURATION / STATISTICS

Enables collection of statistics on database activity.

Type
bool
Context
superuser
Measured default
on
Unit
Metadata snapshot
18

Definition PG 18 manual

Enables collection of statistics on database activity. This parameter is on by default, because the autovacuum daemon needs the collected information. Only superusers and users with the appropriate SET privilege can change this setting.

Measured default history
Version intervalDefault
9.0 – 19on
Analysis & operational context

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

How it works

track_counts feeds PostgreSQL's cumulative database, table, and index activity counters. Autovacuum depends on these counts to decide when tables need vacuum and analyze.

Turning it off removes planner and maintenance telemetry and can prevent normal autovacuum triggering. It does not reset already stored counters by itself.

The statistics are exposed through pg_stat views under snapshot rules controlled by stats_fetch_consistency. Collection is server-wide, while visibility remains privilege controlled. Its superuser context permits an authorized session change without a server restart.

Operational considerations

Enabling or enlarging track_counts without measuring collection and observation overhead.

Confusing collection semantics with a performance-control or I/O-control setting.

Assuming all statistics are immediately current inside a long transaction.

Collecting sensitive query text or identifiers without matching access and retention policy.

Workload guidance

OLAP: Keep track_counts=on for maintenance decisions even if queries are batch oriented. Counter collection is more valuable than the small saving from losing autovacuum inputs.

OLTP: Keep track_counts=on; normal autovacuum and capacity monitoring rely on it. Disable only in a controlled experiment that does not represent a production configuration.

SMALL: Keep track_counts=on. Small systems still need autovacuum and table-activity visibility.

Version history 1
  1. PG 14 → 15changed

Related entries

Further reading

Definition snapshot: english-manuals:a0f435eef635be44196c7d84dd4… · English manual source