Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ucbrf-00ErK5-29 for pgsql-general@arkaria.postgresql.org; Fri, 18 Jul 2025 03:34:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1ucbrd-007Kqb-4L for pgsql-general@arkaria.postgresql.org; Fri, 18 Jul 2025 03:34:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ucbrc-007KqR-Pm for pgsql-general@lists.postgresql.org; Fri, 18 Jul 2025 03:34:25 +0000 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1ucbrb-008MvH-0C for pgsql-general@postgresql.org; Fri, 18 Jul 2025 03:34:24 +0000 Received: by mail-oi1-x229.google.com with SMTP id 5614622812f47-41b6561d3c5so537609b6e.1 for ; Thu, 17 Jul 2025 20:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1752809661; x=1753414461; darn=postgresql.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=gwxHuS56Oz4WBkswBxMvGJG7bcCvyhegzuNmazT0sb4=; b=P/Fhm5N1tf++naapsNdcSt9yqUtckUF3NTJwargXI6cAt+X6x67j41E2yfKwqzKEql Z0qGdCr1z2c1OVmLPAbyFtO8ne8rvu3jKkHv7f11CDvvlmLq8hP/PoaRBCnZ8IPEaO2I CHDO+9BjfLOm6OsPhrflMVflx2DvwjZh4Ki0UqKQydpMDeLEUiM7CQDIeAL6C+5GKRLO U8NGkViO5Cs1FwQKCbTL9CHuCTKg/QLUx/+Xv0zt99693vzNCPdKG856C+vMy4lEpIJp oQFIzA0sKYo66uVvRwk8MgRXt52WHB2DO63dz7+kcvJjnFRPsR2rFZX1ktK6J/2a+Jty ktmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752809661; x=1753414461; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gwxHuS56Oz4WBkswBxMvGJG7bcCvyhegzuNmazT0sb4=; b=RQRqqltog3ThxPt3VPHT1qYUhB5Ms5XkMIo0SYw9tanb3jRvfGNTZ/n2uR6gtwO1Ly VZTOmUNp1qmeuGdEclKVObHD2Psleg3gozbxMtOfSoyel+qYXkNKCc43XrYe6gYX20ux 59Z3SwHO8tSZDO8bw0YC8wicakGYtCm5dQ0p/pAZVSmvJmUpVe2yGaNGAs0SENqOKISd Hi0qgT8lIeNKmj8d13tMNxjeINzNTelEdobyTfmGeEeA+zeRWTnjZInyXOKjj9xUhvZc 6vupujxgt+Z45QWSnl97gXs0g+mCSYvGiHPRQxDMRg+M0gpRrxNBi0BQSsON03tyKJoP nVbQ== X-Gm-Message-State: AOJu0Yz0SrwIkLINeK7kcilZq7q1zRl9v/4seFfPDv6b0gAitl0yPTZ/ +jApoDIb5vountLK6IJJvtH0oKXx0haNSiX5tCgzHfVqKkSWjkSorvNJPD5YU5RpRIKcpUFqmZO 3I16qWLhvwCOGj0vqYgoIDdbSfrXuDkxbRdk5 X-Gm-Gg: ASbGncuSCX1IqtkfsneoTtFtdyszfOY1bHuPXQKbz+4qwGvcIObnBmuErc65wjwBw/X nWpWRwSp4GLOaEx2V+4nNrsdJHsbdiM+ggh/UDJC11RMImQijPB76NXxhiEocyZW9QG64fmIZ8O ww9biAAlA+Em7Gg3tCcrd0Sn84ryXhF9hyI5GagMVlp0I3yyLwldMbVLN1EeWW0HV/lrbOXLw/+ E2GxuZfa3GSyCXnVmUjn8qY4mk5ABAjyR033tMyTQ== X-Google-Smtp-Source: AGHT+IFNjG8ORQRiTj4aE2gbVr+7b6V9vahZg2DsPJORUIP3A0QLj6F/OwURMhnNAVTOecMIctNw8GHv12WK5Dn9WlI= X-Received: by 2002:a05:6808:4fc7:b0:406:6a21:527f with SMTP id 5614622812f47-41d05462454mr7963915b6e.35.1752809660589; Thu, 17 Jul 2025 20:34:20 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ron Johnson Date: Thu, 17 Jul 2025 23:34:09 -0400 X-Gm-Features: Ac12FXzS8YGc3QOt31U7ARRB4PGz9b-xPctnNmnMqIXJoek722KByqvRd4YfD9E Message-ID: Subject: Re: Should we document the cost of pg_database_size()? Alternatives? To: pgsql-general Content-Type: multipart/alternative; boundary="0000000000002dae8e063a2bcd3d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002dae8e063a2bcd3d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Jul 17, 2025 at 8:55=E2=80=AFPM Craig Ringer wrote: [snip] > > FS-based sizing isn't really enough > ---------------- > > Asking users to monitor at the filesystem level works, kind-of, but > it'll lead to confusion due to WAL and temp files in simple installs. > To get decent results they will need to have a separate dedicated > volume for pg_wal. And which temp files are counted will differ; IIRC > pg_database_size() does not count extents created by an in-progress > REINDEX etc, but DOES count temp table sizes, for example. FS-based > monitoring will also include things like spilled pg_replslot spilled > reorder buffers, which can be considerable and aren't reasonably > considered part of the "database size" or included in > pg_database_size(). And of course it can see only the sum of all > database sizes on a multi-database postgres instance unless the user > has one volume per database using distinct tablespaces. So > filesystem-based monitoring is not really a proper replacement. > Whether the filesystem creeps above 90%, 95%, etc because of WAL files or temp files or because of REINDEX or VACUUM FULL / CLUSTER / PG_REPACK is irrelevant. it's the filesystem at 100% that will ruin your day, Thus, we monitor filesystems, and don't monitor database size. If the alarm does ever go off, *then* I check the cause. (This isn't as reactionary as it sounds, because I regularly check replication backlog, for orphan slots, do REINDEXING and CLUSTER one table at a time, and don't let junk onto the cluster disk.) --=20 Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --0000000000002dae8e063a2bcd3d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Thu, Jul 17, 2025 at 8:55=E2=80=AFPM C= raig Ringer <craig.ring= er@enterprisedb.com> wrote:
[snip]

FS-based sizing isn't really enough
----------------

Asking users to monitor at the filesystem level works, kind-of, but
it'll lead to confusion due to WAL and temp files in simple installs. To get decent results they will need to have a separate dedicated
volume for pg_wal. And which temp files are counted will differ; IIRC
pg_database_size() does not count extents created by an in-progress
REINDEX etc, but DOES count temp table sizes, for example. FS-based
monitoring will also include things like spilled pg_replslot spilled
reorder buffers, which can be considerable and aren't reasonably
considered part of the "database size" or included in
pg_database_size(). And of course it can see only the sum of all
database sizes on a multi-database postgres instance unless the user
has one volume per database using distinct tablespaces. So
filesystem-based monitoring is not really a proper replacement.

Whether the filesystem creeps above 90%, 95%, etc = because of WAL files or temp files or because of REINDEX or VACUUM FULL / C= LUSTER / PG_REPACK is irrelevant. it's the filesystem at 100% that will= ruin your day,

Thus, we monitor filesystems, and = don't monitor database size.

If the alarm does ever go off,=C2=A0then=C2=A0I c= heck the cause.=C2=A0 (This isn't as reactionary as it sounds, because = I regularly check replication backlog, for orphan slots, do REINDEXING and = CLUSTER one table at a time, and don't let=C2=A0junk onto the cluster d= isk.)

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'= m still alive.
<Redacted> lobster!
--0000000000002dae8e063a2bcd3d--