mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -44,6 +44,7 @@ EXPLAIN [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] <rep
|
||||
WAL [ <replaceable class="parameter">boolean</replaceable> ]
|
||||
TIMING [ <replaceable class="parameter">boolean</replaceable> ]
|
||||
SUMMARY [ <replaceable class="parameter">boolean</replaceable> ]
|
||||
MEMORY [ <replaceable class="parameter">boolean</replaceable> ]
|
||||
FORMAT { TEXT | XML | JSON | YAML }
|
||||
</synopsis>
|
||||
</refsynopsisdiv>
|
||||
@ -250,6 +251,19 @@ ROLLBACK;
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>MEMORY</literal></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Include information on memory consumption by the query planning phase.
|
||||
Specifically, include the precise amount of storage used by planner
|
||||
in-memory structures, as well as total memory considering allocation
|
||||
overhead.
|
||||
This parameter defaults to <literal>FALSE</literal>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><literal>FORMAT</literal></term>
|
||||
<listitem>
|
||||
|
Reference in New Issue
Block a user