Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK7cR-0001QE-VW for pgsql-committers@arkaria.postgresql.org; Thu, 02 Apr 2020 21:43:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jK7cQ-00043b-Ug for pgsql-committers@arkaria.postgresql.org; Thu, 02 Apr 2020 21:43:22 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK7bX-0002r2-0R for pgsql-committers@lists.postgresql.org; Thu, 02 Apr 2020 21:42:27 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jK7bU-0003vJ-Ke for pgsql-committers@lists.postgresql.org; Thu, 02 Apr 2020 21:42:25 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1jK7bT-0004fh-H2; Thu, 02 Apr 2020 17:42:23 -0400 Date: Thu, 2 Apr 2020 17:42:23 -0400 From: Bruce Momjian To: Peter Eisentraut Cc: pgsql-committers@lists.postgresql.org Subject: Re: pgsql: doc: add namespace column to pg_buffercache example query Message-ID: <20200402214223.GD7251@momjian.us> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 > > > -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 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 +