functions-statistics.md 1.3 KB
Newer Older
K
KyleZhang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
## 9.30. Statistics Information Functions

[9.30.1. Inspecting MCV Lists](functions-statistics.html#FUNCTIONS-STATISTICS-MCV)

[]()

PostgreSQL provides a function to inspect complex statistics defined using the `CREATE STATISTICS` command.

### 9.30.1. Inspecting MCV Lists

[]()

```
pg_mcv_list_items ( pg_mcv_list ) → setof record

```

`pg_mcv_list_items` returns a set of records describing all items stored in a multi-column MCV list. It returns the following columns:

|      Name      |       Type       |           Description           |
|----------------|------------------|---------------------------------|
|    `index`     |    `integer`     |index of the item in the MCV list|
|    `values`    |     `text[]`     |  values stored in the MCV item  |
|    `nulls`     |   `boolean[]`    | flags identifying `NULL` values |
|  `frequency`   |`double precision`|   frequency of this MCV item    |
|`base_frequency`|`double precision`| base frequency of this MCV item |

 The `pg_mcv_list_items` function can be used like this:

```
SELECT m.* FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid),
                pg_mcv_list_items(stxdmcv) m WHERE stxname = 'stts';

```

 Values of the `pg_mcv_list` type can be obtained only from the `pg_statistic_ext_data`.`stxdmcv` column.