]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/view-pg-stats.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / view-pg-stats.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>53.29. pg_stats</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="view-pg-shmem-allocations-numa.html" title="53.28. pg_shmem_allocations_numa" /><link rel="next" href="view-pg-stats-ext.html" title="53.30. pg_stats_ext" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">53.29. <code class="structname">pg_stats</code></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="view-pg-shmem-allocations-numa.html" title="53.28. pg_shmem_allocations_numa">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="views.html" title="Chapter 53. System Views">Up</a></td><th width="60%" align="center">Chapter 53. System Views</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="view-pg-stats-ext.html" title="53.30. pg_stats_ext">Next</a></td></tr></table><hr /></div><div class="sect1" id="VIEW-PG-STATS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">53.29. <code class="structname">pg_stats</code> <a href="#VIEW-PG-STATS" class="id_link">#</a></h2></div></div></div><a id="id-1.10.5.33.2" class="indexterm"></a><p>
3    The view <code class="structname">pg_stats</code> provides access to
4    the information stored in the <a class="link" href="catalog-pg-statistic.html" title="52.51. pg_statistic"><code class="structname">pg_statistic</code></a>
5    catalog.  This view allows access only to rows of
6    <a class="link" href="catalog-pg-statistic.html" title="52.51. pg_statistic"><code class="structname">pg_statistic</code></a> that correspond to tables the
7    user has permission to read, and therefore it is safe to allow public
8    read access to this view.
9   </p><p>
10    <code class="structname">pg_stats</code> is also designed to present the
11    information in a more readable format than the underlying catalog
12    — at the cost that its schema must be extended whenever new slot types
13    are defined for <a class="link" href="catalog-pg-statistic.html" title="52.51. pg_statistic"><code class="structname">pg_statistic</code></a>.
14   </p><div class="table" id="id-1.10.5.33.5"><p class="title"><strong>Table 53.29. <code class="structname">pg_stats</code> Columns</strong></p><div class="table-contents"><table class="table" summary="pg_stats Columns" border="1"><colgroup><col /></colgroup><thead><tr><th class="catalog_table_entry"><p class="column_definition">
15        Column Type
16       </p>
17       <p>
18        Description
19       </p></th></tr></thead><tbody><tr><td class="catalog_table_entry"><p class="column_definition">
20        <code class="structfield">schemaname</code> <code class="type">name</code>
21        (references <a class="link" href="catalog-pg-namespace.html" title="52.32. pg_namespace"><code class="structname">pg_namespace</code></a>.<code class="structfield">nspname</code>)
22       </p>
23       <p>
24        Name of schema containing table
25       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
26        <code class="structfield">tablename</code> <code class="type">name</code>
27        (references <a class="link" href="catalog-pg-class.html" title="52.11. pg_class"><code class="structname">pg_class</code></a>.<code class="structfield">relname</code>)
28       </p>
29       <p>
30        Name of table
31       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
32        <code class="structfield">attname</code> <code class="type">name</code>
33        (references <a class="link" href="catalog-pg-attribute.html" title="52.7. pg_attribute"><code class="structname">pg_attribute</code></a>.<code class="structfield">attname</code>)
34       </p>
35       <p>
36        Name of column described by this row
37       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
38        <code class="structfield">inherited</code> <code class="type">bool</code>
39       </p>
40       <p>
41        If true, this row includes values from child tables, not just the
42        values in the specified table
43       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
44        <code class="structfield">null_frac</code> <code class="type">float4</code>
45       </p>
46       <p>
47        Fraction of column entries that are null
48       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
49        <code class="structfield">avg_width</code> <code class="type">int4</code>
50       </p>
51       <p>
52        Average width in bytes of column's entries
53       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
54        <code class="structfield">n_distinct</code> <code class="type">float4</code>
55       </p>
56       <p>
57        If greater than zero, the estimated number of distinct values in the
58        column.  If less than zero, the negative of the number of distinct
59        values divided by the number of rows.  (The negated form is used when
60        <code class="command">ANALYZE</code> believes that the number of distinct values is
61        likely to increase as the table grows; the positive form is used when
62        the column seems to have a fixed number of possible values.)  For
63        example, -1 indicates a unique column in which the number of distinct
64        values is the same as the number of rows.
65       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
66        <code class="structfield">most_common_vals</code> <code class="type">anyarray</code>
67       </p>
68       <p>
69        A list of the most common values in the column. (Null if
70        no values seem to be more common than any others.)
71       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
72        <code class="structfield">most_common_freqs</code> <code class="type">float4[]</code>
73       </p>
74       <p>
75        A list of the frequencies of the most common values,
76        i.e., number of occurrences of each divided by total number of rows.
77        (Null when <code class="structfield">most_common_vals</code> is.)
78       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
79        <code class="structfield">histogram_bounds</code> <code class="type">anyarray</code>
80       </p>
81       <p>
82        A list of values that divide the column's values into groups of
83        approximately equal population.  The values in
84        <code class="structfield">most_common_vals</code>, if present, are omitted from this
85        histogram calculation.  (This column is null if the column data type
86        does not have a <code class="literal">&lt;</code> operator or if the
87        <code class="structfield">most_common_vals</code> list accounts for the entire
88        population.)
89       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
90        <code class="structfield">correlation</code> <code class="type">float4</code>
91       </p>
92       <p>
93        Statistical correlation between physical row ordering and
94        logical ordering of the column values.  This ranges from -1 to +1.
95        When the value is near -1 or +1, an index scan on the column will
96        be estimated to be cheaper than when it is near zero, due to reduction
97        of random access to the disk.  (This column is null if the column data
98        type does not have a <code class="literal">&lt;</code> operator.)
99       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
100        <code class="structfield">most_common_elems</code> <code class="type">anyarray</code>
101       </p>
102       <p>
103        A list of non-null element values most often appearing within values of
104        the column. (Null for scalar types.)
105       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
106        <code class="structfield">most_common_elem_freqs</code> <code class="type">float4[]</code>
107       </p>
108       <p>
109        A list of the frequencies of the most common element values, i.e., the
110        fraction of rows containing at least one instance of the given value.
111        Two or three additional values follow the per-element frequencies;
112        these are the minimum and maximum of the preceding per-element
113        frequencies, and optionally the frequency of null elements.
114        (Null when <code class="structfield">most_common_elems</code> is.)
115       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
116        <code class="structfield">elem_count_histogram</code> <code class="type">float4[]</code>
117       </p>
118       <p>
119        A histogram of the counts of distinct non-null element values within the
120        values of the column, followed by the average number of distinct
121        non-null elements.  (Null for scalar types.)
122       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
123        <code class="structfield">range_length_histogram</code> <code class="type">anyarray</code>
124       </p>
125       <p>
126        A histogram of the lengths of non-empty and non-null range values of a
127        range type column. (Null for non-range types.)
128       </p>
129       <p>
130        This histogram is calculated using the <code class="function">subtype_diff</code>
131        range function regardless of whether range bounds are inclusive.
132       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
133        <code class="structfield">range_empty_frac</code> <code class="type">float4</code>
134       </p>
135       <p>
136        Fraction of column entries whose values are empty ranges.
137        (Null for non-range types.)
138       </p></td></tr><tr><td class="catalog_table_entry"><p class="column_definition">
139        <code class="structfield">range_bounds_histogram</code> <code class="type">anyarray</code>
140       </p>
141       <p>
142        A histogram of lower and upper bounds of non-empty and non-null range
143        values. (Null for non-range types.)
144       </p>
145       <p>
146        These two histograms are represented as a single array of ranges, whose
147        lower bounds represent the histogram of lower bounds, and upper bounds
148        represent the histogram of upper bounds.
149       </p></td></tr></tbody></table></div></div><br class="table-break" /><p>
150    The maximum number of entries in the array fields can be controlled on a
151    column-by-column basis using the <a class="link" href="sql-altertable.html" title="ALTER TABLE"><code class="command">ALTER
152    TABLE SET STATISTICS</code></a>
153    command, or globally by setting the
154    <a class="xref" href="runtime-config-query.html#GUC-DEFAULT-STATISTICS-TARGET">default_statistics_target</a> run-time parameter.
155   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="view-pg-shmem-allocations-numa.html" title="53.28. pg_shmem_allocations_numa">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="views.html" title="Chapter 53. System Views">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="view-pg-stats-ext.html" title="53.30. pg_stats_ext">Next</a></td></tr><tr><td width="40%" align="left" valign="top">53.28. <code class="structname">pg_shmem_allocations_numa</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 53.30. <code class="structname">pg_stats_ext</code></td></tr></table></div></body></html>