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 1v6sTf-00BC3x-E6 for pgsql-general@arkaria.postgresql.org; Thu, 09 Oct 2025 15:22:47 +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 1v6sTd-006Asg-83 for pgsql-general@arkaria.postgresql.org; Thu, 09 Oct 2025 15:22:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v6sT6-006668-6u for pgsql-general@lists.postgresql.org; Thu, 09 Oct 2025 15:22:13 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v6sT4-000sTw-0r for pgsql-general@lists.postgresql.org; Thu, 09 Oct 2025 15:22:12 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b50645ecfbbso225577166b.1 for ; Thu, 09 Oct 2025 08:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760023330; x=1760628130; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ZHC0E2u8OqI42DRj7fybI8qVM/LisNT+3FwYMMMmHBA=; b=elojd+J+GdxHMQSabJbPW12gUG1eaOzcD0Xxb6TtiDb/MT0vycyR702OL9vqDa4UvC HsMPyYzI6GaMbcxh3A2HajKOVMq1lOlxOzFxrifsWzPKkrnjreU4IoP8NRC1H/Z3Hftm k/gdtZMJCrVXCnjz7q4SabGAJ2Plzdzz/DtmvOqo5H0Bghtrl9NfCHmfCKOmp2J9ofgQ bZhVhFwmex78fDk1RREkLQOxV9UKb/DgkMUZmqpVA225XRxFSy7CDHGORr7bAeEwyaW3 hH3OJ35hZgKD0Z8dunm2Xv9KabmRuCyDg6w1BpSf9wGjVZT057w/AivBChgYTvInanVt k57g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760023330; x=1760628130; h=cc: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=ZHC0E2u8OqI42DRj7fybI8qVM/LisNT+3FwYMMMmHBA=; b=HPloJDOcZF6VEi9WM4WrICG3ExFx+ynIehtsNQ+vNvJBtzlyPQnN1sisATlhXYbYJm +C0QzLNFpMCOD2QBywGO94ZLaXxBWHvjUtFFs/EGSKFmrGRQIiOlR1ag2isEatVxvhl5 R++8vz0yaI5SARxBp2uWvP6fpDxEdFkPCCHUXTLgUeodCJF3R4NnoR4KtLGVegE6SKhS EqksY2QVICH5GTzQgbAXExJR2/VnzuJumns8ZTXWYalmnPV4+Y+9xIxQCVN2aA3jIk96 oR/FuI31muky8+SsWcY/j/6K2hGrdbW/wtzKVtphWmqo8magmVuETcLxitug1xPnRF5/ 4Hvg== X-Forwarded-Encrypted: i=1; AJvYcCU31NIQyJi6Lu8LvQNgKbfJj075LdSj1ZABZgawq5ws5XoCmf4nEev3OJXnMOfljAblKL88fxFqTHp9NAHo@lists.postgresql.org X-Gm-Message-State: AOJu0YxaMn9O+di9DOheEiq6inac6rsforGAk5MF2oxpgDYzU/oAv4ry UtjZ7tpKKbQ5FS4e6ZerGyPmSqUXGRhNJdtLSjGRW7ecOXclSt4pT+2i2D9hPed6+xnz1/3lo79 UrK8h5FMOm2JzeJUeDzLfunK9Nlpy4FBO8KRD X-Gm-Gg: ASbGnctZx8sQRd8w1k1DL7EUUaMQ3RlJ4ez94jLL0rvw/n9qFaLGaIfRG9C1CQ/rM2X ZzVsM/GhziW3Gt/9pFhqRysCgUhxQJpE71WvWX4St9cd6la+U9Cf0RnsbzJcXrkpKfzlbWVn1ag KJs+RRBZQIPGqtkeHqRIBLESb9g77SdkSVsAfumvcmEJkUrZ3Jv4fjLnxYlAA65TxpyhD0+OcyQ whToUZQ2R5qQXwbbImKD6VpP921CHFYER6h++t4rdZwLYH/JzsRGdYqy1Rxu7syjOACYeA= X-Google-Smtp-Source: AGHT+IEG23uQVefgVmTbBOcKQ9Lm2cK+E+Ngv/TCFJyh0R88TnL2++SO4YVCZU1me7GwYlofl0vpFXGFeSyWgswa3rk= X-Received: by 2002:a17:907:3e92:b0:b4d:2ac5:81b4 with SMTP id a640c23a62f3a-b50aa48fc85mr978390666b.19.1760023329587; Thu, 09 Oct 2025 08:22:09 -0700 (PDT) MIME-Version: 1.0 References: <9f175444-6bfc-4c6e-a609-e552d85c45a1@aklaver.com> In-Reply-To: From: veem v Date: Thu, 9 Oct 2025 20:51:56 +0530 X-Gm-Features: AS18NWDTqbv0KxhoaL2VV83_YPEzzGeg_vhIuaG4Ci9gSllUnnrSOais9v3AcDI Message-ID: Subject: Re: Alerting on memory use and instance crash To: Adrian Klaver , sud Cc: Ron Johnson , pgsql-general Content-Type: multipart/alternative; boundary="0000000000005b43af0640bb5d5d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005b43af0640bb5d5d Content-Type: text/plain; charset="UTF-8" My 2cents:- In regards to the memory consumption question of OP:- Wouldn't the column "temp_blks_read" and "temp_blks_written" in pg_stats_statements provide details around the memory consumption i.e. when the query exceeds the work_mem then it tries occupying the temp blocks. Something as below. Correct me if I'm wrong. WITH block_size AS ( SELECT setting::int AS size FROM pg_settings WHERE name = 'block_size' ) SELECT query, calls, pg_size_pretty(temp_blks_read * bs.size) AS temp_read_in_bytes, pg_size_pretty(temp_blks_written * bs.size) AS temp_written_in_bytes FROM pg_stat_statements, block_size bs WHERE temp_blks_read > 0 OR temp_blks_written > 0 ORDER BY temp_blks_written DESC LIMIT 10; On Thu, 9 Oct 2025 at 01:24, Adrian Klaver wrote: > On 10/8/25 11:58, sud wrote: > > Thank you. > > My understanding may be wrong here.And my apology as I am using the > > example of Oracle again even though these two are not the same. But > > being worked for a long time in Oracle so trying to understand exactly > > how it's different. > > > > In oracle RAC(real application cluster) database, we have single > > databases with multiple nodes/instances/memory, which means the > > underlying storage is same but the memory/cpu of each of those instances > > are different and any of the instances can be down but the database > > still operates routing the application traffic of the downed node to > > others. Similarly even in AWS Aurora postgres also there can be multiple > > instances like Writer and Reader instances/nodes and the underlying > > storage being the same. So I was thinking of any such cluster level pg_* > > views available by querying which we would be able to know if any one of > > the nodes is down ? Also , I don't see any such pg_* view which can > > show the statistics of all the instances combinely i.e. cluster level > > statistics. > > > > Do you mean in normal Postgres it's alway a single instance/memory and > > single storage attached? then I also do not see any such cluster level > > views in aws aurora postgres too? Pardon if it's a silly one to ask. > > > > It would be helpful if you specified exactly what variety of Postgres > you are using and it's version. > > If you are using AWS Aurora Postgres then you will need to look at pages > like this: > > > https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Managing.html > > This list is for the community version of Postgres and it's been a long > time since AWS saw fit to have someone on the list and when they where > here they did not really provide answers. > > -- > Adrian Klaver > adrian.klaver@aklaver.com > > > --0000000000005b43af0640bb5d5d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
My 2cents:-
In regards to the memory consum= ption question of OP:- Wouldn't the column "temp_blks_read" a= nd "temp_blks_written" in pg_stats_statements provide details aro= und the memory consumption i.e. when the query exceeds the work_mem then it= tries occupying the temp blocks. Something as below. Correct me if I'm= wrong.=C2=A0

WITH block_size AS (
=C2=A0 SELEC= T setting::int AS size FROM pg_settings WHERE name =3D 'block_size'=
)
SELECT
=C2=A0 query,
=C2=A0 calls,
=C2=A0 pg_size_pretty(= temp_blks_read * bs.size) AS temp_read_in_bytes,
=C2=A0 pg_size_pretty(t= emp_blks_written * bs.size) AS temp_written_in_bytes
FROM pg_stat_statem= ents, block_size bs
WHERE temp_blks_read > 0 OR temp_blks_written >= ; 0
ORDER BY temp_blks_written DESC
LIMIT 10;

On Thu, 9 Oct 2025 at 01:24, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
=
On 10/8/25 11:58, sud wro= te:
> Thank you.
> My understanding may be wrong here.And my apology as I am using the > example of Oracle again even though these=C2=A0two are not the same. B= ut
> being worked for a long time in Oracle so trying to understand exactly=
> how it's different.
>
> In oracle RAC(real application cluster) database, we have single
> databases with multiple nodes/instances/memory, which means the
> underlying storage is same but the memory/cpu of each of those instanc= es
> are different and any of the instances can be=C2=A0down but the databa= se
> still operates routing the application traffic of the downed node to <= br> > others. Similarly even in AWS Aurora postgres also there can be multip= le
> instances like Writer and Reader instances/nodes and the underlying > storage being the same. So I was thinking of any=C2=A0such cluster lev= el pg_*
> views available=C2=A0by querying which we would be able to know if any= one of
> the nodes is down ?=C2=A0 =C2=A0Also , I don't see any such pg_* v= iew which can
> show the statistics of all the instances combinely i.e. cluster level =
> statistics.
>
> Do you mean in normal Postgres it's alway a single instance/memory= and
> single storage attached? then I also do not see any such cluster level=
> views in aws aurora postgres too? Pardon if it's a silly one to as= k.
>

It would be helpful if you specified exactly what variety of Postgres
you are using and it's version.

If you are using AWS Aurora Postgres then you will need to look at pages like this:

https://d= ocs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/AuroraPostgreSQL.Managi= ng.html

This list is for the community version of Postgres and it's been a long=
time since AWS saw fit to have someone on the list and when they where
here they did not really provide answers.

--
Adrian Klaver
adrian.klave= r@aklaver.com


--0000000000005b43af0640bb5d5d--