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 1rX7Lg-008rz6-1a for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 22:21:56 +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 1rX7Le-00GEBB-A7 for pgsql-hackers@arkaria.postgresql.org; Mon, 05 Feb 2024 22:21:54 +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 1rX7Le-00GEB3-0k for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 22:21:54 +0000 Received: from charmander.telsasoft.com ([50.244.222.1] helo=pryzbyj2023.telsasoft) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rX7LZ-005eZh-8f for pgsql-hackers@lists.postgresql.org; Mon, 05 Feb 2024 22:21:53 +0000 Received: by pryzbyj2023.telsasoft (Postfix, from userid 1000) id B17EBFB73; Mon, 5 Feb 2024 16:21:46 -0600 (CST) Date: Mon, 5 Feb 2024 16:21:46 -0600 From: Justin Pryzby To: Alvaro Herrera Cc: pgsql-hackers@lists.postgresql.org, David Rowley , Ashutosh Bapat Subject: Re: pgsql: Add EXPLAIN (MEMORY) to report planner memory consumption Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Up to now, the explain " " (two space) format is not mixed with "=". And, other places which show "Memory" do not use "=". David will remember prior discussions. https://www.postgresql.org/message-id/20200402054120.GC14618@telsasoft.com https://www.postgresql.org/message-id/20200407042521.GH2228@telsasoft.com "Memory: used=%lld bytes allocated=%lld bytes", vs "Buckets: %d (originally %d) Batches: %d (originally %d) Memory Usage: %ldkB\n", There was some discussion about "bytes" - maybe it should instead show kB? (Also, I first thought that "peek" should be "peak", but eventually I realized that's it's as intended.) On Fri, Jan 12, 2024 at 10:53:08PM +0530, Abhijit Menon-Sen wrote: > (Those "bytes" look slightly odd to me in the midst of all the x=y > pieces, but that's probably not worth thinking about.) On Mon, Jan 29, 2024 at 04:55:27PM +0000, Alvaro Herrera wrote: > Add EXPLAIN (MEMORY) to report planner memory consumption > > This adds a new "Memory:" line under the "Planning:" group (which > currently only has "Buffers:") when the MEMORY option is specified. > > In order to make the reporting reasonably accurate, we create a separate > memory context for planner activities, to be used only when this option > is given. The total amount of memory allocated by that context is > reported as "allocated"; we subtract memory in the context's freelists > from that and report that result as "used". We use > MemoryContextStatsInternal() to obtain the quantities. > > The code structure to show buffer usage during planning was not in > amazing shape, so I (Álvaro) modified the patch a bit to clean that up > in passing. > > Author: Ashutosh Bapat > Reviewed-by: David Rowley, Andrey Lepikhov, Jian He, Andy Fan > Discussion: https://www.postgresql.org/message-id/CAExHW5sZA=5LJ_ZPpRO-w09ck8z9p7eaYAqq3Ks9GDfhrxeWBw@mail.gmail.com