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 1tbgHm-00CWQv-O5 for pgsql-performance@arkaria.postgresql.org; Sat, 25 Jan 2025 13:33:19 +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 1tbgHl-002Zmn-In for pgsql-performance@arkaria.postgresql.org; Sat, 25 Jan 2025 13:33:17 +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 1tbgHl-002Zmf-98 for pgsql-performance@lists.postgresql.org; Sat, 25 Jan 2025 13:33:17 +0000 Received: from mail-yb1-xb2a.google.com ([2607:f8b0:4864:20::b2a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tbgHi-001RVo-0x for pgsql-performance@lists.postgresql.org; Sat, 25 Jan 2025 13:33:16 +0000 Received: by mail-yb1-xb2a.google.com with SMTP id 3f1490d57ef6-e53ef7462b6so4865861276.3 for ; Sat, 25 Jan 2025 05:33:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737811993; x=1738416793; 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=J9a+ftKj/H2wyofm8W3J/+DNTQM+FUVJwr+5WnWkAnc=; b=nBJg6Mstv0sTMqVNxRrgftIrltIpekaDKov8jaZIZPMLe8yPhAHVOYEPUejeUiRih0 sxePS1YIQ+03EN0uWrXxTkewRv/uybF1sxxCB3ZvGghphr38FXU5Fu/IKAcv+r/6k0Uj hHESSooedEqEATjMpuBcGElFW5Kx4gB7xRSxp3OWADhBoegxe3KUX7b0Gak13mpbPmhY JKmeAOK50o0INDUgTr5V4bakQf6W+pd770DgDhcrAza1/WefAuI4M0RJ/zRZrO0V5N1m tYW48wc7F+OeswGy4OtURu0kovcBSYyEpZhTVLqeF+ZjfOaXY1t9dwixm7JyGJcQVoAn 8nlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737811993; x=1738416793; 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=J9a+ftKj/H2wyofm8W3J/+DNTQM+FUVJwr+5WnWkAnc=; b=JmkcpXaI1XW8ad4801FmEsIiYQcRZaI25K4jPJ8ATTR2g9uxoPSv0HMCCX44m/SvNi l6FN9CGoApZWyynvedgkEerzLPlpFOXkYI7Phh7Ryez/ENMqp91Lh9vOG5oNsZuVniXr WJOZO6xDpEbFfbux90fPNWSGR0zTPDTYyybnI0bi39HXjnTiRauyW7l1dmCKALg6NgLE XbHU3QRbQhXf2xCWQT65jPQKpYSTE7PXGfJ6TwynZB5n/7qNsz/q5ZoEOk8zwalTixsC K1snrxr/aoJnKkOHWQVKAYHh499k4OR37BTWLWHJKhC77bPTcC/BdTFn7zU5DYA40b5N OwNQ== X-Gm-Message-State: AOJu0Yz7trWO9r7/PM/IT/yPLwN05y6AEKT+474eA5hyDWq9B11O3wgU mXnDxZwi/q52Jylhl5iG0o+w0AeaXfxOnH6yRRQwbRUBFQBt3BnBrJ8iXorLzsAQQavpF56+/F/ J/I4+TQWUXXquYg4lho6lE/4CJqvj1A== X-Gm-Gg: ASbGnctY1CH5baTKvMpr/NAUBqC8CdMVSRls05wMMemzsnFk9eBH2fhBh5+Ba4sfKbU OZqguCBU6knqfnN8XbKKB9WyfdEzblObJSubLLlOsekERkIBEO+A1BQC0azfAgG3LjH7rEurb X-Google-Smtp-Source: AGHT+IE61PuB4CQ4iDbCv4ynEAh06B59IoMnCALW1cXwrSKRpjeemMZGHu7Tku+WaLBrsdxlqHSsrEG9gR96+AloaYw= X-Received: by 2002:a05:690c:6b84:b0:6ef:79d1:2f69 with SMTP id 00721157ae682-6f6eb92fcf9mr277918687b3.31.1737811992808; Sat, 25 Jan 2025 05:33:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pavel Stehule Date: Sat, 25 Jan 2025 14:32:36 +0100 X-Gm-Features: AWEUYZmXSiZ-oL8PBq77C7hjgk-z1SxO3CSOIKxpSCc6wvef6VbijMQt31fMrxU Message-ID: Subject: Re: Any risk or overhead considerations for frequently executing queries against catalog tables? To: Frits Hoogland Cc: pgsql-performance@lists.postgresql.org Content-Type: multipart/alternative; boundary="0000000000008498b2062c87e21e" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000008498b2062c87e21e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi so 25. 1. 2025 v 12:23 odes=C3=ADlatel Frits Hoogland napsal: > For monitoring database behaviour and trying to build an history of > activity, if I would create an application that creates a single connecti= on > and execute something like: > select * from pg_stat_activity; > select * from pg_stat_database; > select * from pg_stat_bgwriter; > select * from pg_stat_wal; > select * from pg_settings; > select * from pg_database; > For which the query is prepared, and execute that every 1 second, would > there be any realistic danger or overhead that should be considered? > My thinking is that the data for these catalogs are all in shared memory > and when executed serially and do not cause any significant resources to = be > taken? > The queries to all tables excluding pg_database every 1 sec will have probably zero impact to performance. I am not sure about pg_database - it is a very important table, and your query can block operations that need exclusive lock to this table. So theoretically, there can be some impact to performance. Regards Pavel > > Thanks, > > *Frits Hoogland* > > > > > --0000000000008498b2062c87e21e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi

so 25. 1. 2025 v=C2=A012:= 23 odes=C3=ADlatel Frits Hoogland <frits.hoogland@gmail.com> napsal:
For monitoring database behaviour and= trying to build an history of activity, if I would create an application t= hat creates a single connection and execute something like:
select * fr= om pg_stat_activity;
select * from pg_stat_database;
se= lect * from pg_stat_bgwriter;
select * from pg_stat_wal;
select * from pg_settings;
select * from pg_database;
For which the query is prepared, and execute that every 1 second, would th= ere be any realistic danger or overhead that should be considered?
My thinking is that the data for these catalogs are all in shared memory = and when executed serially and do not cause any significant resources to be= taken?

The queries to all tabl= es excluding pg_database every 1 sec will have probably zero impact to perf= ormance.

I am not sure about pg_database - it is a= very important table, and your query can block operations that need exclus= ive lock to this table. So theoretically, there can be some impact to perfo= rmance.

Regards

Pavel
=
=C2=A0
Frits Hoogland

<= /div>


--0000000000008498b2062c87e21e--