1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Add pg_shmem_allocations view.

This tells you about allocations that have been made from the main
shared memory segment. The original patch also tried to show information
about dynamic shared memory allocation as well, but I decided to
leave that problem for another time.

Andres Freund and Robert Haas, reviewed by Michael Paquier, Marti
Raudsepp, Tom Lane, Álvaro Herrera, and Kyotaro Horiguchi.

Discussion: http://postgr.es/m/20140504114417.GM12715@awork2.anarazel.de
This commit is contained in:
Robert Haas
2020-01-09 10:59:07 -05:00
parent 5acf6d8bb4
commit ed10f32e37
7 changed files with 212 additions and 4 deletions

View File

@ -8362,6 +8362,11 @@ SCRAM-SHA-256$<replaceable>&lt;iteration count&gt;</replaceable>:<replaceable>&l
<entry>planner statistics</entry>
</row>
<row>
<entry><link linkend="view-pg-shmem-allocations"><structname>pg_shmem_allocations</structname></link></entry>
<entry>shared memory allocations</entry>
</row>
<row>
<entry><link linkend="view-pg-stats-ext"><structname>pg_stats_ext</structname></link></entry>
<entry>extended planner statistics</entry>
@ -10748,6 +10753,86 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
</sect1>
<sect1 id="view-pg-shmem-allocations">
<title><structname>pg_shmem_allocations</structname></title>
<indexterm zone="view-pg-shmem-allocations">
<primary>pg_shmem_allocations</primary>
</indexterm>
<para>
The <structname>pg_shmem_allocations</structname> view shows allocations
made from the server's main shared memory segment. This includes both
memory allocated by <productname>postgres</productname> itself and memory
allocated by extensions using the mechanisms detailed in
<xref linkend="xfunc-shared-addin" />.
</para>
<para>
Note that this view does not include memory allocated using the dynamic
shared memory infrastructure.
</para>
<table>
<title><structname>pg_shmem_allocations</structname> Columns</title>
<tgroup cols="3">
<thead>
<row>
<entry>Name</entry>
<entry>Type</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><structfield>name</structfield></entry>
<entry><type>text</type></entry>
<entry>The name of the shared memory allocation. NULL for unused memory
and <literal>&lt;anonymous&gt;</literal> for anonymous
allocations.</entry>
</row>
<row>
<entry><structfield>off</structfield></entry>
<entry><type>bigint</type></entry>
<entry>The offset at which the allocation starts. NULL for anonymous
allocations and unused memory.</entry>
</row>
<row>
<entry><structfield>size</structfield></entry>
<entry><type>bigint</type></entry>
<entry>Size of the allocation</entry>
</row>
<row>
<entry><structfield>allocated_size</structfield></entry>
<entry><type>bigint</type></entry>
<entry>Size of the allocation including padding. For anonymous
allocations, no information about padding is available, so the
<literal>size</literal> and <literal>allocated_size</literal> columns
will always be equal. Padding is not meaningful for free memory, so
the columns will be equal in that case also.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
Anonymous allocations are allocations that have been made
with <literal>ShmemAlloc()</literal> directly, rather than via
<literal>ShmemInitStruct()</literal> or
<literal>ShmemInitHash()</literal>.
</para>
<para>
By default, the <structname>pg_shmem_allocations</structname> view can be
read only by superusers.
</para>
</sect1>
<sect1 id="view-pg-stats">
<title><structname>pg_stats</structname></title>

View File

@ -3239,7 +3239,7 @@ CREATE FUNCTION make_array(anyelement) RETURNS anyarray
</para>
</sect2>
<sect2>
<sect2 id="xfunc-shared-addin">
<title>Shared Memory and LWLocks</title>
<para>