# track_activity_query_size

> track_activity_query_size — Sets the size reserved for pg_stat_activity.query, in bytes. Observed in PG9.0–19 Beta 3; its last measured boot default is 1 KiB in PG19 Beta 3, with postmaster context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA.
---

> [!NOTE]
> **Fact — official short description:** “Sets the size reserved for pg_stat_activity.query, in bytes.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `postmaster` | Requires a server restart |
| Unit | `B` | Raw unit |
| Range | `100` – `1048576` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Statistics / Cumulative Query and Index Statistics | Upstream classification |
| Latest boot value | `1024` | 1 KiB |
{.fields meta="-"}

## Lifecycle {#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 {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–10 | `1024` | — | 1024 |
| PG11–19 Beta 3 | `1024` | `B` | 1 KiB |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

track_activity_query_size reserves real shared memory for the current-query text of every active session shown in pg_stat_activity.query. It is a byte count fixed at server start.

Long statements are truncated to this storage size; increasing it improves incident context but multiplies memory by the number of backend slots, including configured connection capacity.

It does not change log statement length, pg_stat_statements query-text storage, or application payload limits. Query identifiers can correlate truncated text with other telemetry when compute_query_id is available. Its postmaster context fixes the value at server start; changing it requires a restart.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Choose enough bytes to retain diagnostically useful SQL, then budget approximately that storage across all backend slots rather than active queries alone. Increasing it is a startup shared-memory decision and requires a restart. |
| OLAP | Long generated SQL often needs more than 1kB to remain identifiable. Compare truncation frequency and incident needs against the value multiplied by MaxBackends; this setting incurs memory, not repeated clock-read overhead. |
| Small nodes | Keep the smallest value that preserves useful statement identity. Do not copy a 32kB critical-profile value without multiplying it across connection and worker slots on the small host. |
{.full-width}

## Pigsty {#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 | `8192` | different | `8192` |
| OLAP | `8192` | different | `8192` |
| CRIT | `32768` | different | `32768` |
| TINY | `8192` | different | `8192` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 8192 (dcs); OLAP: PG9.0–19 Beta 3 = 8192 (dcs); CRIT: PG9.0–19 Beta 3 = 32768 (dcs); TINY: PG9.0–19 Beta 3 = 8192 (dcs). Advice, pending human review — Editorial inference, pending maintainer review: The templates retain more query text than upstream for operations, with a larger critical-profile value intended to preserve full diagnostic context.

## Common pitfalls {#common-pitfalls}

- Treating the value as memory only for currently active queries instead of storage reserved across backend slots.
- Forgetting that the unit is bytes and multibyte query text can contain fewer characters than the byte count suggests.
- Expecting it to change log statement length or pg_stat_statements query-text storage.
- Changing it without the required server restart.

## Related parameters {#related-parameters}

[`track_activities`](/parameters/track-activities/) · [`max_connections`](/parameters/max-connections/) · [`compute_query_id`](/parameters/compute-query-id/) · [`log_line_prefix`](/parameters/log-line-prefix/) · [`shared_buffers`](/parameters/shared-buffers/)

## References {#references}

- [PostgreSQL 19 Beta 3 — track_activity_query_size](https://www.postgresql.org/docs/19/runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
