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 1tc6sa-00Fa9Z-C0 for pgsql-performance@arkaria.postgresql.org; Sun, 26 Jan 2025 17:57:05 +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 1tc6sZ-007tq4-2X for pgsql-performance@arkaria.postgresql.org; Sun, 26 Jan 2025 17:57:03 +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 1tc6sY-007tpv-LK for pgsql-performance@lists.postgresql.org; Sun, 26 Jan 2025 17:57:02 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tc6sV-001dKV-2l for pgsql-performance@lists.postgresql.org; Sun, 26 Jan 2025 17:57:01 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-2161eb95317so63468885ad.1 for ; Sun, 26 Jan 2025 09:57:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ardentperf-com.20230601.gappssmtp.com; s=20230601; t=1737914219; x=1738519019; darn=lists.postgresql.org; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:from:to:cc:subject:date:message-id :reply-to; bh=7VBktGsxENq8eqvg2XkXm423r4GthDu5ooC+FYqYoms=; b=UM0cSqFMkdZRKJpU5+QoqPuxXSADs4foZr6ptiAuLR2NLsQcQWktZNq+f8xMtxlDnw OmUAU0JfACHzSve30Zsxsiy7iEp72bngLkOPP9dcmHzUpGXBgSW6LPTuDv5X8Dg8td1S D6voRe/rCM1O0OGMQu9crHq6KyB2gOYg2+xYQ7CaPhZ/ZT3a7QQAdIn7s7/Eh5E1pvEz nlX6mKeviZbIXcNMqyqhFGac1da3zYGaW6m9SMjc8GQi/w1fI2N7bXVQqIyqrj8h51ki /QYomKVcvPE4v6287vz9DTnbP97554VMieZcxbhJtg7w4CyDbHewA8KYdHrc+oOaalY3 ljAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737914219; x=1738519019; h=to:in-reply-to:cc:references:message-id:date:subject:mime-version :from:content-transfer-encoding:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7VBktGsxENq8eqvg2XkXm423r4GthDu5ooC+FYqYoms=; b=NsqpJu46SF8WbHmcb/dgG9DuD/VbJzDHjy0Y/ypntAaR4I8azyi0TURk7H4iJwB2lJ 2BPzO6SBTtcik/o7nTlpuQ2stK2jAZsnO324fX6XoDnb5xG9yDDpO9JT8o4nyRc3M08x dUXO9l0Y81ehfs7Zz7VQgopGtNqDRnAS1OQYfrMJZsQVu1z7QZU1cH0qbHHoUdYlm1hW GOv1ew+HnskZXuI1+A9N6/o/g4ZIyVQj5/bCAZPLd4AkQEV2G+xa5QZGxHLUGpTUhtTc 0t9mFZbnJdOq3RLXJeA5NYa2Bz7qijAS6XZY/q9ui9BMrboZUyui2HhfSAG1/AShAX4o VPag== X-Forwarded-Encrypted: i=1; AJvYcCULNUlx7C23WsPK8u6zpGQMHhyZnlvskFnYDtbXt2iVTLf7zVJA6e84gx77KhQyVI+eqNPdQk4CLydtkXdGT1+XFg==@lists.postgresql.org X-Gm-Message-State: AOJu0Yy4YHGGQoWBDofU6h5W59JCxMtLccrGFZSxCD440WV5ofPxiVyp JVHv56lezMo8++sze6KnKIDztYw5SF1AB1BGBu4MBvSpgS8M9Z1jgThlt00YAQ== X-Gm-Gg: ASbGncsamxukolVEcg32e7Isvkw9fS81sWiogbwMnHbo9IUx3UqC77uw4b2d6CGy3BG sifq2QEGlEodT20RAmLw/jOke+28pOZNlI09ljueiViQMKJ/2wMAX3phTiZ8WoB2xnqDfIJBb8T 3k/AZnKDu22MgASdvzTn4OsAd+ZN0yS66JW9yF4/ctKVfsiY0bTJsf5pgC9Ra2QOuQThg197eRQ ifi+tfLZNAkaqkdfLAoPCTYDvAqXgdin2APjzhOPBEBEx1sAgsfCu90kjkjhvjVXEjkVaunmevB UDrZpZO7+FU5ooivEGGhm8CnhEntLjVFuzcA7V6aVVqeXND7/YbLuZ+y X-Google-Smtp-Source: AGHT+IHj5O7VNtLp8LqoKm9BbcwUfc2Be14tuMJBIeX5imeVl2IhZNzPESvFU/HmdrYUoJiS6O6F3g== X-Received: by 2002:a17:902:f551:b0:215:431f:268a with SMTP id d9443c01a7336-21c3556016amr558364815ad.31.1737914219247; Sun, 26 Jan 2025 09:56:59 -0800 (PST) Received: from smtpclient.apple (97-113-83-230.tukw.qwest.net. [97.113.83.230]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21da3ea5546sm48756175ad.98.2025.01.26.09.56.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 26 Jan 2025 09:56:58 -0800 (PST) Content-Type: multipart/alternative; boundary=Apple-Mail-A8E062A3-188C-47F8-BEF3-5A37B8299E2D Content-Transfer-Encoding: 7bit From: Jeremy Schneider Mime-Version: 1.0 (1.0) Subject: Re: Any risk or overhead considerations for frequently executing queries against catalog tables? Date: Sun, 26 Jan 2025 09:56:47 -0800 Message-Id: <3FC4230E-AFF1-4BEB-99B1-66D1AA9BBBE4@ardentperf.com> References: <0C899A03-5B27-4380-9EA9-59DE2047FDFD@gmail.com> Cc: peter plachta , Pavel Stehule , pgsql-performance@lists.postgresql.org In-Reply-To: <0C899A03-5B27-4380-9EA9-59DE2047FDFD@gmail.com> To: frits.hoogland@gmail.com X-Mailer: iPhone Mail (21H221) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail-A8E062A3-188C-47F8-BEF3-5A37B8299E2D Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable > On Jan 25, 2025, at 2:42=E2=80=AFPM, frits.hoogland@gmail.com wrote: >=20 > One thing I found is that because certain statistics are provided after a q= uery has run, measuring them in a fine grained way shows a peak for somethin= g that in reality is taking place over a period of time. =20 +1 I have also encountered this. I think most stats (pg_stat_statements, block h= it/read counts, object access counts, etc) are all updated at query completi= on time. I think it=E2=80=99s related to the architecture of the statistics c= ollector. The main thing I=E2=80=99ve seen change in real time is fields in p= g_stat_activity (like wait events). As a result, I=E2=80=99m not sure how useful per-second stats on the other v= iews are. Mainly I think it will just tell you which second the query comple= ted, and that=E2=80=99s easy to get from logging (db or app tier). stats fro= m the other views tend to be most useful when normalized over minutes or hou= rs. I wrote out a Postgres observability wishlist two weeks ago and much of it w= ould probably best be added to pg_stat_activity [1]. I wonder if we might eventually want the underlying pg_stat_activity functio= n to have an argument to exclude pulling data that=E2=80=99s less frequently= accessed, similar to how the pg_stat_statements function can exclude query t= ext to be more efficient. -Jeremy 1: https://ardentperf.com/2025/01/08/postgres-per-connection-statistics/ --Apple-Mail-A8E062A3-188C-47F8-BEF3-5A37B8299E2D Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Jan 25, 2025, at 2:42=E2=80=AFPM, frits.hoogland@gmail.com wrote:
=

One thing I found is that because certain statistics are provided afte= r a query has run, measuring them in a fine grained way shows a peak for som= ething that in reality is taking place over a period of time.  

+1

I have also encountere= d this. I think most stats (pg_stat_statements, block hit/read counts, objec= t access counts, etc) are all updated at query completion time. I think it=E2= =80=99s related to the architecture of the statistics collector. The main th= ing I=E2=80=99ve seen change in real time is fields in pg_stat_activity (lik= e wait events).

As a result, I=E2=80=99m not sure h= ow useful per-second stats on the other views are. Mainly I think it will ju= st tell you which second the query completed, and that=E2=80=99s easy to get= from logging (db or app tier). stats from the other views tend to be most u= seful when normalized over minutes or hours.

I wrot= e out a Postgres observability wishlist two weeks ago and much of it would p= robably best be added to pg_stat_activity [1].

I wo= nder if we might eventually want the underlying pg_stat_activity function to= have an argument to exclude pulling data that=E2=80=99s less frequently acc= essed, similar to how the pg_stat_statements function can exclude query text= to be more efficient.

-Jeremy

=



= --Apple-Mail-A8E062A3-188C-47F8-BEF3-5A37B8299E2D--