52.89. pg_stats
Представление pg_stats открывает доступ к информации, хранящейся в каталоге pg_statistic. Это представление даёт доступ только к тем строкам каталога pg_statistic, что соответствуют таблицам, которые пользователь может читать; таким образом, это представление можно без опасений разрешить читать всем.
Кроме того, представление pg_stats специально разработано для подачи информации в более понятном виде, чем нижележащий каталог — ценой того, что схему представления приходится расширять всякий раз, когда для pg_statistic определяются новые типы слотов.
Таблица 52.90. Столбцы pg_stats
Тип столбца Описание |
|---|
Имя схемы, содержащей таблицу |
Имя таблицы |
Имя столбца, описываемого этой строкой |
Если true, в данных этой строки учитываются значения в дочерних столбцах, а не только в указанной таблице |
Доля записей, в которых этот столбец содержит NULL |
Средний размер элементов в столбце, в байтах |
Число больше нуля представляет примерное количество различных значений в столбце. Если это число меньше нуля, его модуль представляет количество различных значений, делённое на количество строк. (Отрицательная форма применяется, когда |
Список самых частых значений в столбце. (NULL, если не находятся значения, встречающиеся чаще других.) |
Список частот самых частых значений, то есть число их вхождений, делённое на общее количество строк. (NULL, когда |
Список значений, разделяющих значения столбца на примерно одинаковые популяции. Значения |
Статистическая корреляция между физическим порядком строк и логическим порядком значений столбца. Допустимые значения лежат в диапазоне -1 .. +1. Когда значение около -1 или +1, сканирование индекса по столбцу будет считаться дешевле, чем когда это значение около нуля, как результат уменьшения случайного доступа к диску. (Этот столбец содержит NULL, если для типа данных столбца не определён оператор |
Список элементов, отличных от NULL, наиболее часто присутствующих в значениях столбца. (NULL для скалярных типов.) |
Список частот самых частых элементов, то есть доля строк, содержащих минимум один экземпляр данного значения. За частотами по элементам следуют два или три дополнительных значения: минимум и максимум предшествующих частот по элементам и дополнительно частота элементов NULL. (Принимает значение NULL, когда |
Гистограмма количеств различных и отличных от NULL элементов в значениях этого столбца, за которой следует среднее количество элементов, отличных от NULL. (Принимает значение NULL для скалярных типов.) |
Максимальным числом записей в полях-массивах можно управлять на уровне столбцов, используя команду ALTER TABLE SET STATISTICS, или глобально, задав параметр времени выполнения default_statistics_target.
52.89. pg_stats
The view pg_stats provides access to the information stored in the pg_statistic catalog. This view allows access only to rows of pg_statistic that correspond to tables the user has permission to read, and therefore it is safe to allow public read access to this view.
pg_stats is also designed to present the information in a more readable format than the underlying catalog — at the cost that its schema must be extended whenever new slot types are defined for pg_statistic.
Table 52.90. pg_stats Columns
Column Type Description |
|---|
Name of schema containing table |
Name of table |
Name of column described by this row |
If true, this row includes inheritance child columns, not just the values in the specified table |
Fraction of column entries that are null |
Average width in bytes of column's entries |
If greater than zero, the estimated number of distinct values in the column. If less than zero, the negative of the number of distinct values divided by the number of rows. (The negated form is used when |
A list of the most common values in the column. (Null if no values seem to be more common than any others.) |
A list of the frequencies of the most common values, i.e., number of occurrences of each divided by total number of rows. (Null when |
A list of values that divide the column's values into groups of approximately equal population. The values in |
Statistical correlation between physical row ordering and logical ordering of the column values. This ranges from -1 to +1. When the value is near -1 or +1, an index scan on the column will be estimated to be cheaper than when it is near zero, due to reduction of random access to the disk. (This column is null if the column data type does not have a |
A list of non-null element values most often appearing within values of the column. (Null for scalar types.) |
A list of the frequencies of the most common element values, i.e., the fraction of rows containing at least one instance of the given value. Two or three additional values follow the per-element frequencies; these are the minimum and maximum of the preceding per-element frequencies, and optionally the frequency of null elements. (Null when |
A histogram of the counts of distinct non-null element values within the values of the column, followed by the average number of distinct non-null elements. (Null for scalar types.) |
The maximum number of entries in the array fields can be controlled on a column-by-column basis using the ALTER TABLE SET STATISTICS command, or globally by setting the default_statistics_target run-time parameter.