Skip to content

pg_stat_statements for postgres 13 does not contain: total_time, min_time, max_time, mean_time, stddev_time columns that cause errors #541

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zagr0 opened this issue Jun 9, 2021 · 6 comments

Comments

@zagr0
Copy link

zagr0 commented Jun 9, 2021

What did you do?
run postgres_exporter for postgresql 13 server

What did you expect to see?
to not have errors and all the metrics should be returned

What did you see instead? Under which circumstances?
there are failures during metrics scraping
pg_stat_statements for postgres 13 does not contain: total_time, min_time, max_time, mean_time, stddev_time columns
https://www.postgresql.org/docs/13/pgstatstatements.html

Environment

  • postgres_exporter version:

postgres_exporter 0.0.1-rev (built with go1.15.8)

  • PostgresSQL version:

13.2.0

  • Logs:
time="2021-06-08T17:02:01Z" level=info msg="Starting Server: :9187" source="postgres_exporter.go:1850"
time="2021-06-08T17:02:31Z" level=info msg="Established new database connection to \"*****:5432\"." source="postgres_exporter.go:983"
time="2021-06-08T17:02:31Z" level=info msg="Semantic Version Changed on \"*****:5432\": 0.0.0 -> 13.2.0" source="postgres_exporter.go:1552"
time="2021-06-08T17:02:31Z" level=info msg="Error running query on database \"******:5432\": pg_stat_statements pq: column \"total_time\" does not exist" source="postgres_exporter.go:1503"
time="2021-06-08T17:02:31Z" level=error msg="queryNamespaceMappings returned 1 errors" source="postgres_exporter.go:1621"
...
@Sebor
Copy link

Sebor commented Jul 20, 2021

I confirm the same problem:

SQL Error [42703]: ERROR: column "total_time" does not exist

Columns min_time/max_time/mean_time/stddev_time also do not exist.

Postgresql version: 13.3

pg_stat_statements extension version: 1.8

@lfdominguez
Copy link

Now is split by plan and exec, so total_time is total_plan_time + total_exec_time...

@dani3lsf
Copy link

I confirm the same problem.
Any news on this topic?

@sysadmind
Copy link
Contributor

pg_stat_statements comes from the queries file. This is a user customizable file, so you can customize the queries to your needs.

@stop-coding
Copy link

what is

Now is split by plan and exec, so total_time is total_plan_time + total_exec_time...

is right?

@secustor
Copy link

secustor commented May 2, 2022

I have replaced the query with

SELECT t2.rolname, t3.datname, queryid, calls, ( total_plan_time + total_exec_time ) / 1000 as total_time_seconds, ( min_plan_time + min_exec_time ) / 1000 as min_time_seconds, ( max_plan_time + max_exec_time ) / 1000 as max_time_seconds, ( mean_plan_time + mean_exec_time ) / 1000 as mean_time_seconds, ( stddev_plan_time + stddev_exec_time )  / 1000 as stddev_time_seconds, rows, shared_blks_hit, shared_blks_read, shared_blks_dirtied, shared_blks_written, local_blks_hit, local_blks_read, local_blks_dirtied, local_blks_written, temp_blks_read, temp_blks_written, blk_read_time / 1000 as blk_read_time_seconds, blk_write_time / 1000 as blk_write_time_seconds FROM pg_stat_statements t1 JOIN pg_roles t2 ON (t1.userid=t2.oid) JOIN pg_database t3 ON (t1.dbid=t3.oid) WHERE t2.rolname != 'rdsadmin' AND queryid IS NOT NULL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants