> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/19/internals/views/view-pg-stats-ext.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 53.30. pg\_stats\_ext \#

### 53.30. `pg_stats_ext` [#](#view-pg-stats-ext) <a href="#view-pg-stats-ext" id="view-pg-stats-ext"></a>

檢視表 `pg_stats_ext` 提供對資料庫中每個擴充統計資訊物件之資訊的存取，結合了儲存在 [`pg_statistic_ext`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext.md) 與 [`pg_statistic_ext_data`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext-data.md) 系統目錄中的資訊。此檢視表只允許存取 [`pg_statistic_ext`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext.md) 與 [`pg_statistic_ext_data`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext-data.md) 中對應於使用者所擁有之資料表的資料列，因此允許公開讀取此檢視表是安全的。

`pg_stats_ext` 也被設計為以比底層系統目錄更易讀的格式呈現資訊——代價是每當有新的擴充統計資訊類型加入 [`pg_statistic_ext`](https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext.md) 時，就必須擴充此檢視表的結構。

#### 表 53.30. `pg_stats_ext` 欄位 [#](#view-pg-stats-ext-columns) <a href="#view-pg-stats-ext-columns" id="view-pg-stats-ext-columns"></a>

| <p>欄位類型</p><p>說明</p>                                                                                                                                                                                                                                         |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><code>schemaname</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-namespace.md"><code>pg\_namespace</code></a>.<code>nspname</code>）</p><p>包含資料表之綱要的名稱</p>                                               |
| <p><code>tablename</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-class.md"><code>pg\_class</code></a>.<code>relname</code>）</p><p>資料表名稱</p>                                                              |
| <p><code>statistics\_schemaname</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-namespace.md"><code>pg\_namespace</code></a>.<code>nspname</code>）</p><p>包含擴充統計資訊物件之綱要的名稱</p>                              |
| <p><code>statistics\_name</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext.md"><code>pg\_statistic\_ext</code></a>.<code>stxname</code>）</p><p>擴充統計資訊物件的名稱</p>                                |
| <p><code>statistics\_owner</code> <code>name</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-authid.md"><code>pg\_authid</code></a>.<code>rolname</code>）</p><p>擴充統計資訊物件的擁有者</p>                                             |
| <p><code>attnames</code> <code>name\[]</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-attribute.md"><code>pg\_attribute</code></a>.<code>attname</code>）</p><p>擴充統計資訊物件所包含之欄位的名稱</p>                                        |
| <p><code>exprs</code> <code>text\[]</code></p><p>擴充統計資訊物件所包含的運算式</p>                                                                                                                                                                                         |
| <p><code>kinds</code> <code>char\[]</code></p><p>此筆記錄所啟用的擴充統計資訊物件類型</p>                                                                                                                                                                                      |
| <p><code>inherited</code> <code>bool</code> （參照 <a href="https://docs.postgresql.tw/19/internals/catalogs/catalog-pg-statistic-ext-data.md"><code>pg\_statistic\_ext\_data</code></a>.<code>stxdinherit</code>）</p><p>若為 true，統計資訊包含來自子資料表的值，而不只是指定關聯中的值</p> |
| <p><code>n\_distinct</code> <code>pg\_ndistinct</code></p><p>欄位值組合的相異值個數（N-distinct）。若大於零，表示該組合中相異值的估計數量。若小於零，則為相異值數量除以資料列數量所得之值的負數。（當 <code>ANALYZE</code> 認為相異值的數量可能會隨著資料表成長而增加時，使用負值形式；當欄位看起來只有固定數量的可能值時，使用正值形式。）例如，-1 表示一個唯一的欄位組合，其相異組合的數量與資料列數量相同。</p>  |
| <p><code>dependencies</code> <code>pg\_dependencies</code></p><p>函數相依性統計資訊</p>                                                                                                                                                                               |
| <p><code>most\_common\_vals</code> <code>text\[]</code></p><p>這些欄位中最常見之值組合的清單。（若沒有任何組合看起來比其他組合更常見，則為 null。）</p>                                                                                                                                              |
| <p><code>most\_common\_val\_nulls</code> <code>bool\[]</code></p><p>最常見之值組合的 NULL 旗標清單。（當 <code>most\_common\_vals</code> 為 null 時，此欄位也為 null。）</p>                                                                                                          |
| <p><code>most\_common\_freqs</code> <code>float8\[]</code></p><p>最常見之組合的頻率清單，亦即每個組合的出現次數除以資料列總數。（當 <code>most\_common\_vals</code> 為 null 時，此欄位也為 null。）</p>                                                                                                 |
| <p><code>most\_common\_base\_freqs</code> <code>float8\[]</code></p><p>最常見之組合的基礎頻率清單，亦即各值頻率的乘積。（當 <code>most\_common\_vals</code> 為 null 時，此欄位也為 null。）</p>                                                                                                  |

<br>

陣列欄位中的項目數上限，可以使用 [`ALTER TABLE SET STATISTICS`](https://docs.postgresql.tw/19/reference/sql-commands/sql-altertable.md) 命令逐欄控制，或透過設定 [default\_statistics\_target](https://docs.postgresql.tw/19/server-administration/runtime-config/runtime-config-query.md#GUC-DEFAULT-STATISTICS-TARGET) 執行期參數進行全域控制。

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-stats-ext.html)（原文版本：18.6；核對日期：2026-10-10）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.postgresql.tw/19/internals/views/view-pg-stats-ext.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
