Parameter · Statistics / Cumulative Query and Index Statistics
track_activity_query_size
Sets the size reserved for pg_stat_activity.query, in bytes.
- Default:
1kB - Type: integer (B)
- Range: 100B … 1MB
- Applies: Restart required
In plain words
pg_stat_activity shows the text of each running query, but only the first part of it: by default 1024 bytes. Long generated queries (ORMs, big IN lists) are therefore cut off, often before the interesting part. Raising this shows more text at the cost of a little shared memory per connection.
For DBAs and operators
Memory is reserved at server start for every possible backend: about track_activity_query_size × (max_connections + autovacuum and background workers …). At 1024 bytes and 100 connections that is ~100 kB; at 32 kB it is a few MB, which is fine. The maximum is 1 MB. Restart required.
The stored text is cut at this many bytes minus one (respecting multibyte characters). The full text can still be found in pg_stat_statements (normalized) or in the log via log_min_duration_statement.
Support tip: if a customer sends you a "query" from pg_stat_activity that ends mid-word, it was truncated here, not by their client. Values of 4096–32768 are common on systems with long ORM queries.
How to change it
Change in postgresql.conf or ALTER SYSTEM, then restart the server.