バージョンごとのドキュメント一覧

53.5. pg_backend_memory_contexts #

The view <structname>pg_backend_memory_contexts</structname> displays all the memory contexts of the server process attached to the current session. pg_backend_memory_contextsビューは、現在のセッションにアタッチされているサーバプロセスのすべてのメモリコンテキストを表示します。

<structname>pg_backend_memory_contexts</structname> contains one row for each memory context. pg_backend_memory_contextsの各1行が各々のメモリコンテキストを格納します。

表53.5 pg_backend_memory_contexts

<title><structname>pg_backend_memory_contexts</structname> Columns</title>

Column Type 列 型

Description 説明

name text

Name of the memory context メモリコンテキストの名前

ident text

Identification information of the memory context. This field is truncated at 1024 bytes メモリコンテキストの識別情報。このフィールドは1024バイトで切り捨てられる

type text

Type of the memory context メモリコンテキストの種別

level int4

The 1-based level of the context in the memory context hierarchy. The level of a context also shows the position of that context in the <structfield>path</structfield> column. メモリコンテキスト階層内の、1から始まるコンテキストのレベル。 コンテキストのレベルは、path列内のそのコンテキストの位置も示します。

path int4[]

Array of transient numerical identifiers to describe the memory context hierarchy. The first element is for <literal>TopMemoryContext</literal>, subsequent elements contain intermediate parents and the final element contains the identifier for the current context. メモリコンテキスト階層を説明する一時的な数値識別子の配列。 最初の要素はTopMemoryContext用で、後続の要素には中間の親が含まれ、最後の要素には現在のコンテキストの識別子が含まれます。

total_bytes int8

Total bytes allocated for this memory context このメモリコンテキストで確保した合計バイト数

total_nblocks int8

Total number of blocks allocated for this memory context このメモリコンテキストで確保した合計ブロック数

free_bytes int8

Free space in bytes バイト単位の空き領域

free_chunks int8

Total number of free chunks 空きチャンクの数

used_bytes int8

Used space in bytes バイト単位の使用領域


By default, the <structname>pg_backend_memory_contexts</structname> view can be read only by superusers or roles with the privileges of the <literal>pg_read_all_stats</literal> role. デフォルトではpg_backend_memory_contextsビューはスーパーユーザか、pg_read_all_statsロールの権限を持つユーザのみが読み取り専用でアクセスできます。

Since memory contexts are created and destroyed during the running of a query, the identifiers stored in the <structfield>path</structfield> column can be unstable between multiple invocations of the view in the same query. The example below demonstrates an effective usage of this column and calculates the total number of bytes used by <literal>CacheMemoryContext</literal> and all of its children: メモリコンテキストは問い合わせの実行中に作成および破棄されるため、path列に格納されている識別子は、同じ問い合わせでビューを複数回呼び出しても一定にならない可能性があります。 以下の例は、この列の効果的な使用方法を示し、CacheMemoryContextとそのすべての子が使用する合計バイト数を計算しています。

WITH memory_contexts AS (
    SELECT * FROM pg_backend_memory_contexts
)
SELECT sum(c1.total_bytes)
FROM memory_contexts c1, memory_contexts c2
WHERE c2.name = 'CacheMemoryContext'
AND c1.path[c2.level] = c2.path[c2.level];

The <link linkend="queries-with">Common Table Expression</link> is used to ensure the context IDs in the <structfield>path</structfield> column match between both evaluations of the view. 共通テーブル式を使用して、path列のコンテキストIDがビューの両方の評価で一致するようにします。