From: | hubert depesz lubaczewski <depesz(at)depesz(dot)com> |
---|---|
To: | Magnus Hagander <magnus(at)hagander(dot)net> |
Cc: | Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Getting pg_stat_database data takes significant time |
Date: | 2021-08-13 11:10:11 |
Message-ID: | 20210813111010.GA5785@depesz.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Aug 12, 2021 at 06:20:23PM +0200, Magnus Hagander wrote:
> On Thu, Aug 12, 2021 at 4:38 PM hubert depesz lubaczewski
> <depesz(at)depesz(dot)com> wrote:
> >
> > On Thu, Aug 12, 2021 at 11:32:15AM +0200, Magnus Hagander wrote:
> > > Which database are you connected to? If you just want to look at the
> > > global stats, it might help to be connected to a database that is
> > > *not* the one with all the tables in -- e.g. connect to "postgres" and
> > > query pg_stat_database looking for values on a different database? In
> > > this case it would open files for "global", for "database postgres"
> > > and "shared relations" only and skip the file for your db with many
> > > objects. I think.
> >
> > I'm connected to the db I need data about, and I need data from virtualy
> > all columns of pg_stat_database.
> Try connecting to a different database, while still querying all columns.
Damn, this is huge difference:
=$ time psql -d postgres -c "select * from pg_stat_database where datname = 'appdb'" -qAtX > /dev/null
real 0m0.058s
user 0m0.026s
sys 0m0.013s
=$ time psql -d appdb -c "select * from pg_stat_database where datname = 'appdb'" -qAtX > /dev/null
real 0m0.466s
user 0m0.031s
sys 0m0.008s
Not sure if I can make the monioring software use different connection for this
one particular query, though. Will check with them. Thanks.
Best regards,
depesz
From | Date | Subject | |
---|---|---|---|
Next Message | Zahir Lalani | 2021-08-13 11:35:29 | RE: Multi-master replication |
Previous Message | Ram Charan Kallem | 2021-08-13 10:20:41 | RE: Multiple Postgres process are running in background |