

# aurora\$1stat\$1memctx\$1usage
<a name="aurora_stat_memctx_usage"></a>

报告每个 PostgreSQL 进程的内存上下文使用情况。

## 语法
<a name="aurora_stat_memctx_usage-syntax"></a>

```
aurora_stat_memctx_usage()
```

## 参数
<a name="aurora_stat_memctx_usage-arguments"></a>

无

## 返回类型
<a name="aurora_stat_memctx_usage-return-type"></a>

包含以下列的 SETOF 记录：
+ `pid` – 进程的 ID。
+ `name` – 内存上下文的名称。
+ `allocated` – 内存上下文从底层内存子系统获得的字节数。
+ `used` – 提交给内存上下文客户端的字节数。
+ `instances` – 当前存在的此类上下文的计数。

## 使用说明
<a name="aurora_stat_memctx_usage-usage-notes"></a>

此函数显示每个 PostgreSQL 进程的内存上下文使用情况。有些进程标为 `anonymous`。这些进程不会被公开，因为其中包含受限制的关键字。

从以下 Aurora PostgreSQL 版本开始提供此函数：
+ 15.3 及更高的 15 版本
+ 14.8 及更高的 14 版本
+ 13.11 及更高的 13 版本
+ 12.15 及更高的 12 版本
+ 11.20 及更高的 11 版本

## 示例
<a name="aurora_stat_memctx_usage-examples"></a>

以下示例显示了调用 `aurora_stat_memctx_usage` 函数的结果。

```
=> SELECT * 
     FROM aurora_stat_memctx_usage();
  
    pid| name                            | allocated |   used  | instances 
-------+---------------------------------+-----------+---------+-----------
123864 | Miscellaneous                   |     19520 |   15064 |         3 
123864 | Aurora File Context             |      8192 |     616 |         1 
123864 | Aurora WAL Context              |      8192 |     296 |         1 
123864 | CacheMemoryContext              |    524288 |  422600 |         1 
123864 | Catalog tuple context           |     16384 |   13736 |         1 
123864 | ExecutorState                   |     32832 |   28304 |         1 
123864 | ExprContext                     |      8192 |    1720 |         1 
123864 | GWAL record construction        |      1024 |     832 |         1 
123864 | MdSmgr                          |      8192 |     296 |         1 
123864 | MessageContext                  |    532480 |  353832 |         1 
123864 | PortalHeapMemory                |      1024 |     488 |         1 
123864 | PortalMemory                    |      8192 |     576 |         1 
123864 | printtup                        |      8192 |     296 |         1 
123864 | RelCache hash table entries     |      8192 |    8152 |         1 
123864 | RowDescriptionContext           |      8192 |    1344 |         1 
123864 | smgr relation context           |      8192 |     296 |         1 
123864 | Table function arguments        |      8192 |     352 |         1 
123864 | TopTransactionContext           |      8192 |     632 |         1 
123864 | TransactionAbortContext         |     32768 |     296 |         1 
123864 | WAL record construction         |     50216 |   43904 |         1 
123864 | hash table                      |     65536 |   52744 |         6 
123864 | Relation metadata               |    191488 |  124240 |        87 
104992 | Miscellaneous                   |      9280 |    7728 |         3 
104992 | Aurora File Context             |      8192 |     376 |         1 
104992 | Aurora WAL Context              |      8192 |     296 |         1 
104992 ||Autovacuum Launcher             |      8192 |     296 |         1 
104992 | Autovacuum database list        |     16384 |     744 |         2 
104992 | CacheMemoryContext              |    262144 |  140288 |         1 
104992 | Catalog tuple context           |      8192 |     296 |         1 
104992 | GWAL record construction        |      1024 |     832 |         1 
104992 | MdSmgr                          |      8192 |     296 |         1 
104992 | PortalMemory                    |      8192 |     296 |         1 
104992 | RelCache hash table entries     |      8192 |     296 |         1 
104992 | smgr relation context           |      8192 |     296 |         1 
104992 | Autovacuum start worker (tmp)   |      8192 |     296 |         1 
104992 | TopTransactionContext           |     16384 |     592 |         2 
104992 | TransactionAbortContext         |     32768 |     296 |         1 
104992 | WAL record construction         |     50216 |   43904 |         1 
104992 | hash table                      |     49152 |   34024 |         4 
(39 rows)
```

一些受限制的关键字将被隐藏，输出将如下所示：

```
postgres=>SELECT * 
     FROM aurora_stat_memctx_usage();
   
    pid| name                            | allocated |   used  | instances 
-------+---------------------------------+-----------+---------+-----------
  5482 | anonymous                       |      8192 |     456 |         1 
  5482 | anonymous                       |      8192 |     296 |         1
```