

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# aurora\_stat\_memctx\_usage
<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
```