Movatterモバイル変換


[0]ホーム

URL:


September 25, 2025: PostgreSQL 18 Released!
Supported Versions:Current (18) /17 /16 /15 /14
Development Versions:devel
53.5. pg_backend_memory_contexts
Prev UpChapter 53. System ViewsHome Next

53.5. pg_backend_memory_contexts#

The viewpg_backend_memory_contexts displays all the memory contexts of the server process attached to the current session.

pg_backend_memory_contexts contains one row for each memory context.

Table 53.5. pg_backend_memory_contexts Columns

Column Type

Description

nametext

Name of the memory context

identtext

Identification information of the memory context. This field is truncated at 1024 bytes

typetext

Type of the memory context

levelint4

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 thepath column.

pathint4[]

Array of transient numerical identifiers to describe the memory context hierarchy. The first element is forTopMemoryContext, subsequent elements contain intermediate parents and the final element contains the identifier for the current context.

total_bytesint8

Total bytes allocated for this memory context

total_nblocksint8

Total number of blocks allocated for this memory context

free_bytesint8

Free space in bytes

free_chunksint8

Total number of free chunks

used_bytesint8

Used space in bytes


By default, thepg_backend_memory_contexts view can be read only by superusers or roles with the privileges of thepg_read_all_stats role.

Since memory contexts are created and destroyed during the running of a query, the identifiers stored in thepath 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 byCacheMemoryContext and all of its children:

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

TheCommon Table Expression is used to ensure the context IDs in thepath column match between both evaluations of the view.


Prev Up Next
53.4. pg_available_extension_versions Home 53.6. pg_config

Submit correction

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please usethis form to report a documentation issue.


[8]ページ先頭

©2009-2025 Movatter.jp