此条目与一个提议的PostgreSQL功能相关,该功能在公开发布之前已被撤回。
pg_get_process_memory_contexts()
是一个用于检索PostgreSQL进程内存上下文的系统函数。
pg_get_process_memory_contexts()
在PostgreSQL 18中添加,但随后被撤销。
用法
pg_get_process_memory_contexts (pid
integer
,summary
boolean
,timeout
float
) → setof record (
name
TEXT
,
ident TEXT,
type TEXT,
path INT[],
level INT,
total_bytes BIGINT,
total_nblocks BIGINT,
free_bytes BIGINT,
free_chunks BIGINT,
used_bytes BIGINT,
num_agg_contexts INT,
stats_timestamp TIMESTAMPTZ
)
所有三个参数都必须提供。
请注意,pg_log_backend_memory_contexts()
可用于将进程内存上下文转储到日志文件中。
变更历史
示例
pg_get_process_memory_contexts()
的基本用法示例
postgres=# SELECT * FROM pg_get_process_memory_contexts(pg_backend_pid(), true, 10) LIMIT 1; -[ RECORD 1 ]----+------------------------------ name | TopMemoryContext ident | type | AllocSet path | {1} level | 1 total_bytes | 198848 total_nblocks | 8 free_bytes | 31864 free_chunks | 20 used_bytes | 166984 num_agg_contexts | 1 stats_timestamp | 2025-04-12 15:18:08.613994+09
有用链接
- PostgreSQL 18: 添加函数报告后端内存上下文 - Daniel Westermann / dbi services 的 2025 年 4 月博客文章