Re: Question on pg_stat* views - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Question on pg_stat* views
Date
Msg-id CAKAnmmJ=fAU3PgrOAg20a5nH+8g=BjB8NLTEX+Mpp8kUiiyhHg@mail.gmail.com
Whole thread Raw
In response to Re: Question on pg_stat* views  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
Adrian and Veem were saying:
 > so does it mean that we should increase the pg_stat_statement.max to further higher value?

Yes, you should raise this setting if you find your queries are getting pushed out. Moving to version 17 will also help, as myself and others have been working on normalizing more queries, which means less overall entries in pg_stat_statements, and more room before hitting pg_stat_statements.max. But bump it to 10000 for now.

Now what I don't know is if pg_stat_statement exhibits the same behavior
as the core statistics and resets on an unclean shutdown.

It does - pg_stat_statements will be emptied out if Postgres restarts after a crash.

> 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?

Typically, you use pg_stat_statements in conjunction with a good log_min_duration_statements setting to allow you to see specific slow queries as well as the aggregated info. It's also a good idea to rotate things via cron, as you mention.

Cheers,
Greg

pgsql-general by date:

Previous
From: KK CHN
Date:
Subject: Re: CLOSE_WAIT pileup and Application Timeout
Next
From: Paul Brindusa
Date:
Subject: libpq5 error