Question on pg_stat* views

From: veem v <veema0000(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Question on pg_stat* views
Date: 2024-10-06 19:11:24
Message-ID: CAB+=1TWE48wbtY8Sa1T2vpWHkaQ7wcodBnx8WNyTRB5D=7j1Mw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
As per my understanding , the pg_stat_statements stores the aggregated
statistics of the query execution history(with almost near real time
executions) and the max number of statements or queries it can store
depends on the pg_stat_statement.max value(which I am seeing as ~5000 in
pg_settings). I have below questions,

1)Doing a count(*) on pg_stat_statements giving ~4818. But still
pg_stat_statements_info showing ~1990 as "dealloc" which means there are
more sql queries coming up and they are getting flushed out of the
pg_stat_statements, so does it mean that we should increase the
pg_stat_statement.max to further higher value?

2)The stats_reset column in pg_stat_statements_info view is showing as 16th
august , so does it mean that, whatever query stats are getting logged in
the pg_stat_statements, those are the aggregated stats for all the
executions that have happened since the day 16th august till today? Also as
we have not done any "stats reset" manually , so does it happen
automatically when the DB instance restarts or with any other database
events?

3)As pg_stat_statements holds the aggregated stats of all the execution for
a particular sql query ,so it's not easy to identify if in the past at some
point in time the same query suffered and thus went for high response time.
So to debug such performance issues scenarios , is it advisable to insert
the records from this pg_stat* views to another table manually periodically
through a cron job?

Regards
Veem

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2024-10-06 20:27:30 Re: Question on pg_stat* views
Previous Message Alvaro Herrera 2024-10-06 18:37:18 Re: CLOSE_WAIT pileup and Application Timeout