> 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/internals/views/view-pg-stats-ext.md).

# 53.30. pg\_stats\_ext \#

The view `pg_stats_ext` provides access to information about each extended statistics object in the database, combining information stored in the [`pg_statistic_ext`](/internals/catalogs/catalog-pg-statistic-ext.md) and [`pg_statistic_ext_data`](/internals/catalogs/catalog-pg-statistic-ext-data.md) catalogs. This view allows access only to rows of [`pg_statistic_ext`](/internals/catalogs/catalog-pg-statistic-ext.md) and [`pg_statistic_ext_data`](/internals/catalogs/catalog-pg-statistic-ext-data.md) that correspond to tables the user owns, and therefore it is safe to allow public read access to this view.

`pg_stats_ext` is also designed to present the information in a more readable format than the underlying catalogs — at the cost that its schema must be extended whenever new types of extended statistics are added to [`pg_statistic_ext`](/internals/catalogs/catalog-pg-statistic-ext.md).

**Table 53.30. `pg_stats_ext` Columns**

| <p>Column Type</p><p>Description</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>schemaname</code> <code>name</code> (references <a href="/pages/p7uH9oRd2ZTbQCzy1qKB"><code>pg\_namespace</code></a>.<code>nspname</code>)</p><p>Name of schema containing table</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| <p><code>tablename</code> <code>name</code> (references <a href="/pages/b1fii6hWVNacZFXaxWON"><code>pg\_class</code></a>.<code>relname</code>)</p><p>Name of table</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| <p><code>statistics\_schemaname</code> <code>name</code> (references <a href="/pages/p7uH9oRd2ZTbQCzy1qKB"><code>pg\_namespace</code></a>.<code>nspname</code>)</p><p>Name of schema containing extended statistics object</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| <p><code>statistics\_name</code> <code>name</code> (references <a href="/pages/PBajbiDNekbIsqryC08c"><code>pg\_statistic\_ext</code></a>.<code>stxname</code>)</p><p>Name of extended statistics object</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p><code>statistics\_owner</code> <code>name</code> (references <a href="/pages/nyEMOe5gQKgypFQTDbjS"><code>pg\_authid</code></a>.<code>rolname</code>)</p><p>Owner of the extended statistics object</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| <p><code>attnames</code> <code>name\[]</code> (references <a href="/pages/VopJygmvPNyHGB2zfl0Z"><code>pg\_attribute</code></a>.<code>attname</code>)</p><p>Names of the columns included in the extended statistics object</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| <p><code>exprs</code> <code>text\[]</code></p><p>Expressions included in the extended statistics object</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| <p><code>kinds</code> <code>char\[]</code></p><p>Types of extended statistics object enabled for this record</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <p><code>inherited</code> <code>bool</code> (references <a href="/pages/AIQRBZRFDnJZoWuygAJD"><code>pg\_statistic\_ext\_data</code></a>.<code>stxdinherit</code>)</p><p>If true, the stats include values from child tables, not just the values in the specified relation</p>                                                                                                                                                                                                                                                                                                                                                                                                          |
| <p><code>n\_distinct</code> <code>pg\_ndistinct</code></p><p>N-distinct counts for combinations of column values. If greater than zero, the estimated number of distinct values in the combination. If less than zero, the negative of the number of distinct values divided by the number of rows. (The negated form is used when <code>ANALYZE</code> believes that the number of distinct values is likely to increase as the table grows; the positive form is used when the column seems to have a fixed number of possible values.) For example, -1 indicates a unique combination of columns in which the number of distinct combinations is the same as the number of rows.</p> |
| <p><code>dependencies</code> <code>pg\_dependencies</code></p><p>Functional dependency statistics</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| <p><code>most\_common\_vals</code> <code>text\[]</code></p><p>A list of the most common combinations of values in the columns. (Null if no combinations seem to be more common than any others.)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p><code>most\_common\_val\_nulls</code> <code>bool\[]</code></p><p>A list of NULL flags for the most common combinations of values. (Null when <code>most\_common\_vals</code> is.)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| <p><code>most\_common\_freqs</code> <code>float8\[]</code></p><p>A list of the frequencies of the most common combinations, i.e., number of occurrences of each divided by total number of rows. (Null when <code>most\_common\_vals</code> is.)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| <p><code>most\_common\_base\_freqs</code> <code>float8\[]</code></p><p>A list of the base frequencies of the most common combinations, i.e., product of per-value frequencies. (Null when <code>most\_common\_vals</code> is.)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

<br>

The maximum number of entries in the array fields can be controlled on a column-by-column basis using the [`ALTER TABLE SET STATISTICS`](/reference/sql-commands/sql-altertable.md) command, or globally by setting the [default\_statistics\_target](/server-administration/runtime-config/runtime-config-query.md#GUC-DEFAULT-STATISTICS-TARGET) run-time parameter.

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/view-pg-stats-ext.html)（英文原文，待翻譯）


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
