Describe the issue:
The postgres_exporter pg_stat_statements query files read the standard pg_stat_statements view in five separate collectors.
Four collectors export left(s.query, 40). The aggregate collector does not use s.query, but still reads the text-enabled view.
PostgreSQL must load the complete retained query-text storage before applying left(). If pg_stat_statements contains large utility statements - such as COPY commands with large literal VALUES lists—the query-text file can grow to hundreds of MiB. Each scrape can then read and materialize that data five times.
This can make exporter scrapes exceed their timeout and consume significant database and exporter resources. Limiting the output to 40 characters does not avoid the underlying query-text read.
PostgreSQL provides pg_stat_statements(false) specifically for collecting statistics without loading query text.
Describe the expected behavior:
pgMonitor should provide an option to collect these metrics without retrieving query text.
One compatibility-preserving approach would be separate no-query-text collector files for each supported PostgreSQL version. These could:
- query
public.pg_stat_statements(false);
- retain the existing metric names and labels;
- emit an empty
query label;
- continue exporting
queryid, role, database, timing, row and WAL metrics.
Existing collector files could remain unchanged so current dashboards continue displaying query prefixes. Documentation should explain the observability and performance trade-off.
Tell us about your environment:
- pgMonitor version: current
development branch query definitions
- Container or non-container: applicable to both
- PostgreSQL version: 13–17
- Exporter: postgres_exporter with custom query files
Describe the issue:
The postgres_exporter
pg_stat_statementsquery files read the standardpg_stat_statementsview in five separate collectors.Four collectors export
left(s.query, 40). The aggregate collector does not uses.query, but still reads the text-enabled view.PostgreSQL must load the complete retained query-text storage before applying
left(). Ifpg_stat_statementscontains large utility statements - such asCOPYcommands with large literalVALUESlists—the query-text file can grow to hundreds of MiB. Each scrape can then read and materialize that data five times.This can make exporter scrapes exceed their timeout and consume significant database and exporter resources. Limiting the output to 40 characters does not avoid the underlying query-text read.
PostgreSQL provides
pg_stat_statements(false)specifically for collecting statistics without loading query text.Describe the expected behavior:
pgMonitor should provide an option to collect these metrics without retrieving query text.
One compatibility-preserving approach would be separate no-query-text collector files for each supported PostgreSQL version. These could:
public.pg_stat_statements(false);querylabel;queryid, role, database, timing, row and WAL metrics.Existing collector files could remain unchanged so current dashboards continue displaying query prefixes. Documentation should explain the observability and performance trade-off.
Tell us about your environment:
developmentbranch query definitions