select open change scope Open full search

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

CONFIGURATION / STATISTICS

track_activities

Read PG 18 manual ↗

Enables the collection of information on the currently executing command of each session, along with its identifier and the time when that command began execution.

Type
bool
Context
superuser
Measured default
on
Unit
Metadata snapshot
18

Definition PG 18 manual

Enables the collection of information on the currently executing command of each session, along with its identifier and the time when that command began execution. This parameter is on by default. Note that even when enabled, this information is only visible to superusers, roles with privileges of the pg_read_all_stats role and the user owning the sessions being reported on (including sessions belonging to a role they have the privileges of), so it should not represent a security risk. 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_activities records each session's current command, query identifier, and timing metadata for pg_stat_activity. Access remains privilege-filtered even when collection is enabled.

Turning it off removes essential live observability but does not terminate or speed up the command itself. The text stored per session is bounded by track_activity_query_size.

The switch can be changed by authorized users, so monitoring should detect sessions reporting disabled activity. It is separate from cumulative counters controlled by track_counts. Its superuser context permits an authorized session change without a server restart.

Operational considerations

Turning it off and losing the current-command evidence needed to diagnose blocking or runaway sessions.

Confusing live activity collection with cumulative counters controlled by track_counts.

Assuming on makes every session's query text visible to every role; visibility remains privilege filtered.

Ignoring that an authorized session can disable its own activity reporting in the permitted context.

Workload guidance

OLAP: Keep on for long analytical sessions; live phase and wait context is especially valuable during resource contention. If overhead is suspected, measure it explicitly before accepting the observability loss from off.

OLTP: Keep on in production so pg_stat_activity can show the current command, query ID, and timing needed for incident response. Restrict view privileges and size track_activity_query_size separately rather than disabling activity collection to hide text.

SMALL: Keep on. The setting is a boolean collection gate, not a buffer size; reduce query-text memory with track_activity_query_size only after preserving enough text for diagnosis.

Version history 3
  1. PG 14 → 15changed
  2. PG 13 → 14changed
  3. PG 9.6 → 10changed

Related entries

Further reading

Definition snapshot: english-manuals:36ff16225c226ee44543a0467a0… · English manual source