Faster way of estimating database size

From: Sam Saffron <sam(dot)saffron(at)gmail(dot)com>
To: PGSQL Mailing List <pgsql-general(at)postgresql(dot)org>
Subject: Faster way of estimating database size
Date: 2018-06-15 00:29:02
Message-ID: CAAtdryMMgOaRdGiDcvQgTFRWKZB_V5ZXVi3MhzcB-=HSR+r5Dw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi there,

At the moment we are using:

SELECT pg_database.datname, pg_database_size(pg_database.datname) as
size FROM pg_database

To gather size of databases for monitoring purposes in Prometheus.

Our pg stat logging now shows this is our number one query cause we
seem to be running it for some crazy reason 19 times a minute. Clearly
this is too much and we should (and will) cache results for a bit.

Nonetheless, I notice it take 400ms to run on our cluster (with a few
200 dbs) and was wondering if there is a quicker way of estimating
this number?

Sam

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Charlin Barak 2018-06-15 00:47:28 Question on Buckets and Batches in explain plan
Previous Message Daniel Lagerman 2018-06-14 23:32:45 Re: Impact of multixact "members" limit exceeded