From: Bruce Momjian <bruce@momjian.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: doc: add namespace column to pg_buffercache example query
Date: Thu, 2 Apr 2020 17:42:23 -0400
Message-ID: <20200402214223.GD7251@momjian.us> (raw)
In-Reply-To: <a1ffbfda-59d2-5732-e5fb-3df8582b6434@2ndquadrant.com>
References: <E1jJOFV-0004d4-Dz@gemulon.postgresql.org>
<a1ffbfda-59d2-5732-e5fb-3df8582b6434@2ndquadrant.com>
On Thu, Apr 2, 2020 at 07:35:50AM +0200, Peter Eisentraut wrote:
> On 2020-03-31 23:16, Bruce Momjian wrote:
> > doc: add namespace column to pg_buffercache example query
> >
> > Without the namespace, the table name could be ambiguous.
> >
> > Reported-by: adunham@arbormetrix.com
> >
> > Discussion: https://postgr.es/m/158155175140.23798.2189464781144503491@wrigleys.postgresql.org
> >
> > Backpatch-through: 9.5
>
> <screen>
> -regression=# SELECT c.relname, count(*) AS buffers
> +regression=# SELECT n.nspname, c.relname, count(*) AS buffers
> FROM pg_buffercache b INNER JOIN pg_class c
> ON b.relfilenode = pg_relation_filenode(c.oid) AND
> b.reldatabase IN (0, (SELECT oid FROM pg_database
> WHERE datname = current_database()))
> - GROUP BY c.relname
> - ORDER BY 2 DESC
> + JOIN pg_namespace n ON n.oid = c.relnamespace
> + GROUP BY n.nspname, c.relname
> + ORDER BY 3 DESC
> LIMIT 10;
>
> Seems kind of confusing to use INNER JOIN once and then JOIN the other time.
Agreed, INNER removed.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: bruce@momjian.us, peter.eisentraut@2ndquadrant.com
Subject: Re: pgsql: doc: add namespace column to pg_buffercache example query
In-Reply-To: <20200402214223.GD7251@momjian.us>
References: <E1jJOFV-0004d4-Dz@gemulon.postgresql.org> <a1ffbfda-59d2-5732-e5fb-3df8582b6434@2ndquadrant.com> <20200402214223.GD7251@momjian.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox