public inbox for pgsql-novice@postgresql.org
help / color / mirror / Atom feedIs it possible to turn on pg_stat_extensions at a database level
8+ messages / 4 participants
[nested] [flat]
* Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-12 08:54 Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
0 siblings, 1 reply; 8+ messages in thread
From: Subramanian,Ramachandran @ 2026-03-12 08:54 UTC (permalink / raw)
To: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
Hello,
I have turned on pg_stat_extension for an instance. This instance has many databases. I want to confine the statistics to only one database.
Is it possible to do this?
LG
Ram
Freundliche Grüße
i. A. Ramachandran Subramanian
Zentralbereich Informationstechnologie
Alte Leipziger Lebensversicherung a.G.
Hallesche Krankenversicherung a.G.
Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814
Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
Wiltrud Pekarek, Udo Wilcsek
Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum
______________________
ALH Gruppe
Alte Leipziger-Platz 1, 61440 Oberursel
Tel.: +49 (6171) 66-4882
Fax: +49 (6171) 66-800-4882
E-Mail: ramachandran.subramanian@alte-leipziger.de
www.alte-leipziger.de
www.hallesche.de
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-12 09:30 hubert depesz lubaczewski <depesz@depesz.com>
parent: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
0 siblings, 1 reply; 8+ messages in thread
From: hubert depesz lubaczewski @ 2026-03-12 09:30 UTC (permalink / raw)
To: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
On Thu, Mar 12, 2026 at 08:54:04AM +0000, Subramanian,Ramachandran wrote:
> I have turned on pg_stat_extension for an instance. This instance has many databases. I want to confine the statistics to only one database.
> Is it possible to do this?
Do you mean pg_stat_statements?
If no - sorry, never heard of pg_stat_extension.
If yes - nope. stats are global. You can limit what you're analysing
from stats by adding appropriate where condition, like:
SELECT
*
FROM
pg_stat_statements AS pss
JOIN pg_database AS d ON pss.dbid = d.oid
WHERE
d.datname = 'postgres';
Best regards,
depesz
^ permalink raw reply [nested|flat] 8+ messages in thread
* AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-12 09:33 Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
parent: hubert depesz lubaczewski <depesz@depesz.com>
0 siblings, 2 replies; 8+ messages in thread
From: Subramanian,Ramachandran @ 2026-03-12 09:33 UTC (permalink / raw)
To: depesz@depesz.com <depesz@depesz.com>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
Yes, I mistyped .
Pg_stat_statements.
I meant to ask if the extension can be created only for one database, so that the details from the other databases are not recorded.
LG
Ram
Freundliche Grüße
i. A. Ramachandran Subramanian
Zentralbereich Informationstechnologie
Alte Leipziger Lebensversicherung a.G.
Hallesche Krankenversicherung a.G.
Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814
Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
Wiltrud Pekarek, Udo Wilcsek
Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum
______________________
ALH Gruppe
Alte Leipziger-Platz 1, 61440 Oberursel
Tel.: +49 (6171) 66-4882
Fax: +49 (6171) 66-800-4882
E-Mail: ramachandran.subramanian@alte-leipziger.de
www.alte-leipziger.de
www.hallesche.de
-----Ursprüngliche Nachricht-----
Von: depesz@depesz.com <depesz@depesz.com>
Gesendet: Donnerstag, 12. März 2026 10:30
An: Subramanian,Ramachandran IT-md-db <ramachandran.subramanian@alte-leipziger.de>
Cc: pgsql-novice@lists.postgresql.org
Betreff: Re: Is it possible to turn on pg_stat_extensions at a database level
On Thu, Mar 12, 2026 at 08:54:04AM +0000, Subramanian,Ramachandran wrote:
> I have turned on pg_stat_extension for an instance. This instance has many databases. I want to confine the statistics to only one database.
> Is it possible to do this?
Do you mean pg_stat_statements?
If no - sorry, never heard of pg_stat_extension.
If yes - nope. stats are global. You can limit what you're analysing from stats by adding appropriate where condition, like:
SELECT
*
FROM
pg_stat_statements AS pss
JOIN pg_database AS d ON pss.dbid = d.oid WHERE
d.datname = 'postgres';
Best regards,
depesz
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-12 09:38 hubert depesz lubaczewski <depesz@depesz.com>
parent: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
1 sibling, 1 reply; 8+ messages in thread
From: hubert depesz lubaczewski @ 2026-03-12 09:38 UTC (permalink / raw)
To: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
On Thu, Mar 12, 2026 at 09:33:29AM +0000, Subramanian,Ramachandran wrote:
> I meant to ask if the extension can be created only for one database, so that the details from the other databases are not recorded.
So, no. You can't.
Best regards,
depesz
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-12 19:59 Laurenz Albe <laurenz.albe@cybertec.at>
parent: hubert depesz lubaczewski <depesz@depesz.com>
0 siblings, 1 reply; 8+ messages in thread
From: Laurenz Albe @ 2026-03-12 19:59 UTC (permalink / raw)
To: depesz@depesz.com; Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
On Thu, 2026-03-12 at 10:38 +0100, hubert depesz lubaczewski wrote:
> On Thu, Mar 12, 2026 at 09:33:29AM +0000, Subramanian,Ramachandran wrote:
> > I meant to ask if the extension can be created only for one database, so that the details from the other databases are not recorded.
>
> So, no. You can't.
... but there is no need to do that.
If you are only interested in the statistics for statements on a single database,
add a WHERE condition with the database's object ID, like
WHERE dbid = 47110815
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 8+ messages in thread
* AW: AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-13 05:54 Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
parent: Laurenz Albe <laurenz.albe@cybertec.at>
0 siblings, 1 reply; 8+ messages in thread
From: Subramanian,Ramachandran @ 2026-03-13 05:54 UTC (permalink / raw)
To: Laurenz Albe <laurenz.albe@cybertec.at>; depesz@depesz.com <depesz@depesz.com>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
Coming from the mainframe world, we always assume that there is a lot of CPU/IO expense to monitor and collect statistics from unnecessary Databases.
This is why I wanted the collection of the statitstics itself to be restricted to just one Database.
LG
Ram
Freundliche Grüße
i. A. Ramachandran Subramanian
Zentralbereich Informationstechnologie
Alte Leipziger Lebensversicherung a.G.
Hallesche Krankenversicherung a.G.
Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814
Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
Wiltrud Pekarek, Udo Wilcsek
Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum
______________________
ALH Gruppe
Alte Leipziger-Platz 1, 61440 Oberursel
Tel.: +49 (6171) 66-4882
Fax: +49 (6171) 66-800-4882
E-Mail: ramachandran.subramanian@alte-leipziger.de
www.alte-leipziger.de
www.hallesche.de
-----Ursprüngliche Nachricht-----
Von: Laurenz Albe <laurenz.albe@cybertec.at>
Gesendet: Donnerstag, 12. März 2026 21:00
An: depesz@depesz.com; Subramanian,Ramachandran IT-md-db <ramachandran.subramanian@alte-leipziger.de>
Cc: pgsql-novice@lists.postgresql.org
Betreff: Re: AW: Is it possible to turn on pg_stat_extensions at a database level
On Thu, 2026-03-12 at 10:38 +0100, hubert depesz lubaczewski wrote:
> On Thu, Mar 12, 2026 at 09:33:29AM +0000, Subramanian,Ramachandran wrote:
> > I meant to ask if the extension can be created only for one database, so that the details from the other databases are not recorded.
>
> So, no. You can't.
... but there is no need to do that.
If you are only interested in the statistics for statements on a single database, add a WHERE condition with the database's object ID, like
WHERE dbid = 47110815
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: AW: AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-13 06:58 Laurenz Albe <laurenz.albe@cybertec.at>
parent: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
0 siblings, 0 replies; 8+ messages in thread
From: Laurenz Albe @ 2026-03-13 06:58 UTC (permalink / raw)
To: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>; depesz@depesz.com <depesz@depesz.com>; +Cc: pgsql-novice@lists.postgresql.org <pgsql-novice@lists.postgresql.org>
On Fri, 2026-03-13 at 05:54 +0000, Subramanian,Ramachandran wrote:
> Coming from the mainframe world, we always assume that there is a lot of
> CPU/IO expense to monitor and collect statistics from unnecessary Databases.
>
> This is why I wanted the collection of the statitstics itself to be restricted
> to just one Database.
Ok, now you know that you cannot get it.
I doubt that there are databases where monitoring is unnecessary:
- if there is nothing doing in that database, that won't be a lot of statistics
to collect
- if there is a lot going on in that database, the load will be noteworthy
and can affect your other, necessary, databases in the same cluster, so
you need the statistics to diagnose such problems
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 8+ messages in thread
* Re: AW: Is it possible to turn on pg_stat_extensions at a database level
@ 2026-03-17 10:59 vrms <vrms@netcologne.de>
parent: Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
1 sibling, 0 replies; 8+ messages in thread
From: vrms @ 2026-03-17 10:59 UTC (permalink / raw)
To: pgsql-novice@lists.postgresql.org
As far as I understand the matter the extension starts gathering
statistical information on statements in all databases of a cluster once
'pg_stat_statments' is mentioned in the 'shared_preload_libraries'
setting (including all overhead coming with it) and does nothing without it.
CREATE EXTENSION pg_stat_statements just adds the view to look at these,
based on the WHERE clauses mentioned already.
It does not even have to be created inside that database you want to use
it for.
all best
Gunnar
On 3/12/26 10:33, Subramanian,Ramachandran wrote:
> Yes, I mistyped .
>
> Pg_stat_statements.
>
> I meant to ask if the extension can be created only for one database, so that the details from the other databases are not recorded.
>
> LG
>
> Ram
>
>
>
>
>
> Freundliche Grüße
>
> i. A. Ramachandran Subramanian
> Zentralbereich Informationstechnologie
>
> Alte Leipziger Lebensversicherung a.G.
>
>
> Hallesche Krankenversicherung a.G.
>
>
>
>
>
>
>
> Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
> Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
> Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814
>
>
>
>
>
>
> Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
> Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
> Wiltrud Pekarek, Udo Wilcsek
> Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
> Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei
>
>
>
>
>
> Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum
>
>
>
>
>
> ______________________
>
> ALH Gruppe
> Alte Leipziger-Platz 1, 61440 Oberursel
> Tel.: +49 (6171) 66-4882
> Fax: +49 (6171) 66-800-4882
> E-Mail: ramachandran.subramanian@alte-leipziger.de
> www.alte-leipziger.de
> www.hallesche.de
>
>
>
> -----Ursprüngliche Nachricht-----
> Von: depesz@depesz.com <depesz@depesz.com>
> Gesendet: Donnerstag, 12. März 2026 10:30
> An: Subramanian,Ramachandran IT-md-db <ramachandran.subramanian@alte-leipziger.de>
> Cc: pgsql-novice@lists.postgresql.org
> Betreff: Re: Is it possible to turn on pg_stat_extensions at a database level
>
> On Thu, Mar 12, 2026 at 08:54:04AM +0000, Subramanian,Ramachandran wrote:
>> I have turned on pg_stat_extension for an instance. This instance has many databases. I want to confine the statistics to only one database.
>> Is it possible to do this?
> Do you mean pg_stat_statements?
>
> If no - sorry, never heard of pg_stat_extension.
>
> If yes - nope. stats are global. You can limit what you're analysing from stats by adding appropriate where condition, like:
>
> SELECT
> *
> FROM
> pg_stat_statements AS pss
> JOIN pg_database AS d ON pss.dbid = d.oid WHERE
> d.datname = 'postgres';
>
> Best regards,
>
> depesz
>
^ permalink raw reply [nested|flat] 8+ messages in thread
end of thread, other threads:[~2026-03-17 10:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 08:54 Is it possible to turn on pg_stat_extensions at a database level Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
2026-03-12 09:30 ` hubert depesz lubaczewski <depesz@depesz.com>
2026-03-12 09:33 ` AW: Is it possible to turn on pg_stat_extensions at a database level Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
2026-03-12 09:38 ` Re: AW: Is it possible to turn on pg_stat_extensions at a database level hubert depesz lubaczewski <depesz@depesz.com>
2026-03-12 19:59 ` Re: AW: Is it possible to turn on pg_stat_extensions at a database level Laurenz Albe <laurenz.albe@cybertec.at>
2026-03-13 05:54 ` AW: AW: Is it possible to turn on pg_stat_extensions at a database level Subramanian,Ramachandran <ramachandran.subramanian@alte-leipziger.de>
2026-03-13 06:58 ` Re: AW: AW: Is it possible to turn on pg_stat_extensions at a database level Laurenz Albe <laurenz.albe@cybertec.at>
2026-03-17 10:59 ` Re: AW: Is it possible to turn on pg_stat_extensions at a database level vrms <vrms@netcologne.de>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox