Re: Question on pg_stat* views

From: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: veem v <veema0000(at)gmail(dot)com>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Question on pg_stat* views
Date: 2024-10-07 13:23:08
Message-ID: CAKAnmmJ=fAU3PgrOAg20a5nH+8g=BjB8NLTEX+Mpp8kUiiyhHg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Paul Brindusa 2024-10-07 13:45:01 libpq5 error
Previous Message KK CHN 2024-10-07 11:30:47 Re: CLOSE_WAIT pileup and Application Timeout