> 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-exprs.md). Agents can also search and read this documentation through its [MCP server](https://docs.postgresql.tw/~gitbook/mcp).

# 53.31. pg\_stats\_ext\_exprs \#

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

檢視表 `pg_stats_ext_exprs` 可用來存取擴充統計資訊物件中所包含之所有運算式的相關資訊，它結合了儲存在 [`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_exprs` 也被設計成以比底層系統目錄更易讀的格式呈現資訊——代價是每當 `pg_statistic_ext` 中統計資訊的結構改變時，它的結構定義（schema）就必須跟著擴充。

#### 表 53.31. `pg_stats_ext_exprs` 欄位 [#](#view-pg-stats-ext-exprs-columns) <a href="#view-pg-stats-ext-exprs-columns" id="view-pg-stats-ext-exprs-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>expr</code> <code>text</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>null\_frac</code> <code>float4</code></p><p>運算式項目中為 null 的比例</p>                                                                                                                                                                                     |
| <p><code>avg\_width</code> <code>int4</code></p><p>運算式項目的平均寬度，以位元組為單位</p>                                                                                                                                                                                     |
| <p><code>n\_distinct</code> <code>float4</code></p><p>若大於零，則為運算式中相異值的估計數量。若小於零，則為相異值數量除以資料列數量後的負值。（當 <code>ANALYZE</code> 認為相異值的數量可能隨資料表成長而增加時，使用負值形式；當運算式看起來具有固定數量的可能值時，則使用正值形式。）例如，-1 表示唯一的運算式，其相異值數量與資料列數量相同。</p>                                          |
| <p><code>most\_common\_vals</code> <code>anyarray</code></p><p>運算式中最常見值的清單。（若沒有任何值看起來比其他值更常見，則為 null。）</p>                                                                                                                                                    |
| <p><code>most\_common\_freqs</code> <code>float4\[]</code></p><p>最常見值的頻率清單，也就是每個值的出現次數除以資料列總數。（當 <code>most\_common\_vals</code> 為 null 時，此欄位也為 null。）</p>                                                                                                    |
| <p><code>histogram\_bounds</code> <code>anyarray</code></p><p>將運算式的值分成數量大約相等之各組的值清單。<code>most\_common\_vals</code> 中的值（若有）不納入此直方圖計算。（若運算式的資料型別沒有 <code><</code> 運算子，或 <code>most\_common\_vals</code> 清單已涵蓋整個母體，則此運算式為 null。）</p>                            |
| <p><code>correlation</code> <code>float4</code></p><p>實體資料列順序與運算式值之邏輯順序間的統計相關性。其範圍為 -1 到 +1。當此值接近 -1 或 +1 時，由於減少了對磁碟的隨機存取，針對該運算式的索引掃描會被估算為比此值接近零時更便宜。（若運算式的資料型別沒有 <code><</code> 運算子，則此運算式為 null。）</p>                                                        |
| <p><code>most\_common\_elems</code> <code>anyarray</code></p><p>在運算式的值中最常出現的非 null 元素值清單。（純量型別則為 null。）</p>                                                                                                                                                   |
| <p><code>most\_common\_elem\_freqs</code> <code>float4\[]</code></p><p>最常見元素值的頻率清單，也就是包含至少一個該值實例的資料列比例。在各元素頻率之後會接著兩個或三個額外的值；它們分別是前述各元素頻率的最小值與最大值，以及（視情況）null 元素的頻率。（當 <code>most\_common\_elems</code> 為 null 時，此欄位也為 null。）</p>                              |
| <p><code>elem\_count\_histogram</code> <code>float4\[]</code></p><p>運算式各值中相異非 null 元素值個數的直方圖，後面接著相異非 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-exprs.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-exprs.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.
