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 1jJsWI-0007Md-9c for pgsql-committers@arkaria.postgresql.org; Thu, 02 Apr 2020 05:36:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jJsWH-00032i-1I for pgsql-committers@arkaria.postgresql.org; Thu, 02 Apr 2020 05:36:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJsWG-00032b-S8 for pgsql-committers@lists.postgresql.org; Thu, 02 Apr 2020 05:36:00 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jJsWA-00078W-2I for pgsql-committers@lists.postgresql.org; Thu, 02 Apr 2020 05:36:00 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 513B25C01A2; Thu, 2 Apr 2020 01:35:52 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 02 Apr 2020 01:35:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=Rz6/3oUl6OEUzmCq//GaYTjvYFPdknuR/ZIvive3t jE=; b=obpB9kw7vtspT/1ihj5D81b+laCzYN0Es8XkCx6Dpw3JZ9t7t4bzxcaNy 9Ctxyw/66Jouj6PvQJRQUzPdZxsnBgCLJ2MykdMy53JgA9VLiJQSLWcIYNEfhuE/ gLXVHHT3WtbY1rwD8rKJWehEIwLXC8IOxhTxFx+Vya6u2Seo30LLabqplNmJJtuT onF2+ureFpRhy+nkXP7uFCFHr+HZEx6XXw0llPotT+Bx0EwnGYMSS/WP2qftxmXL iX56dB/Iq9dUtbS4VEgjaikpFfAYkUYj1TQjTPTZqebXShkxIUEoX7M/qFfL01pD PiIpOjoWxOpdBomUGnzUu9P0IeGsA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrtdefgdeljecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhfhokffffgggjggtgfesthejredttdefjeenucfhrhhomheprfgvthgv rhcugfhishgvnhhtrhgruhhtuceophgvthgvrhdrvghishgvnhhtrhgruhhtsedvnhguqh hurggurhgrnhhtrdgtohhmqeenucffohhmrghinhepphhoshhtghhrrdgvshdpvdhnughq uhgrughrrghnthdrtghomhenucfkphepleefrddvgedvrddvudefrddvgedunecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepphgvthgvrhdrvghi shgvnhhtrhgruhhtsedvnhguqhhurggurhgrnhhtrdgtohhm X-ME-Proxy: Received: from april.pezone.net (p5df2d5f1.dip0.t-ipconnect.de [93.242.213.241]) by mail.messagingengine.com (Postfix) with ESMTPA id 8CF2B328005E; Thu, 2 Apr 2020 01:35:51 -0400 (EDT) Subject: Re: pgsql: doc: add namespace column to pg_buffercache example query To: Bruce Momjian , pgsql-committers@lists.postgresql.org References: From: Peter Eisentraut Organization: 2ndQuadrant Message-ID: Date: Thu, 2 Apr 2020 07:35:50 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services