pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: hubert depesz lubaczewski <depesz@depesz.com>
Cc: pgsql-general <pgsql-general@lists.postgresql.org>
Subject: Re: Getting pg_stat_database data takes significant time
Date: Thu, 12 Aug 2021 09:08:27 -0400
Message-ID: <202108121308.ewma4t6jv2e5@alvherre.pgsql> (raw)
In-Reply-To: <20210811163355.GA20926@depesz.com>

On 2021-Aug-11, hubert depesz lubaczewski wrote:

> On Wed, Aug 11, 2021 at 10:16:13AM -0400, Alvaro Herrera wrote:
> > 1. this depends on reading the stats file; that's done once per
> > transaction.  So if you run the query twice in a transaction, the second
> > time will take less time.  You can know how much time is spent reading
> > that file by subtracting both times.
> 
> Yeah. I noticed. Looks like loading the stats file is the culprit. But
> does that mean that the whole stats file has to be read at once? I just
> need stats on db, not on relations?

As I recall there is one file per database containing everything
pertaining to that database, and you cannot read it partially.

Maybe you can use stats_temp_directory to put these files in faster
or less busy storage -- a RAM disk perhaps?

-- 
Álvaro Herrera              Valdivia, Chile  —  https://www.EnterpriseDB.com/
"Those who use electric razors are infidels destined to burn in hell while
we drink from rivers of beer, download free vids and mingle with naked
well shaved babes." (http://slashdot.org/comments.pl?sid=44793&cid=4647152)





view thread (13+ messages)  latest in thread

Message-ID: <202108121308.ewma4t6jv2e5@alvherre.pgsql>
Permalink:  ../202108121308.ewma4t6jv2e5@alvherre.pgsql/
Also on:    postgresql.org/message-id/202108121308.ewma4t6jv2e5@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@alvh.no-ip.org, depesz@depesz.com
  Subject: Re: Getting pg_stat_database data takes significant time
  In-Reply-To: <202108121308.ewma4t6jv2e5@alvherre.pgsql>
  References: <20210811163355.GA20926@depesz.com> <202108121308.ewma4t6jv2e5@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox