<para>
Similarly to per-column statistics, extended statistics are stored in
- a system catalog called <structname>pg_statistic_ext</structname>, but
- there is also a more convenient view <structname>pg_stats_ext</structname>.
+ a system catalog called <structname>pg_statistic_ext</structname>.
To inspect the statistics <literal>s1</literal> defined above,
you may do this:
<programlisting>
-SELECT tablename, staname, attnums, depsbytes
- FROM pg_stats_ext WHERE staname = 's1';
- tablename | staname | attnums | depsbytes
------------+---------+---------+-----------
- t | s1 | 1 2 | 40
+SELECT staname,stadependencies FROM pg_statistic_ext WHERE staname = 's1';
+ staname | stadependencies
+---------+--------------------------------------------
+ s1 | [{1 => 2 : 1.000000}, {2 => 1 : 1.000000}]
(1 row)
</programlisting>
WHERE NOT pg_is_other_temp_schema(N.oid)
AND relkind = 'S';
-CREATE VIEW pg_stats_ext AS
- SELECT
- N.nspname AS schemaname,
- C.relname AS tablename,
- S.staname AS staname,
- S.stakeys AS attnums,
- length(s.standistinct::bytea) AS ndistbytes,
- length(S.stadependencies::bytea) AS depsbytes
- FROM (pg_statistic_ext S JOIN pg_class C ON (C.oid = S.starelid))
- LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace);
-
CREATE VIEW pg_stats WITH (security_barrier) AS
SELECT
nspname AS schemaname,
JOIN pg_attribute a ON (((c.oid = a.attrelid) AND (a.attnum = s.staattnum))))
LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)))
WHERE ((NOT a.attisdropped) AND has_column_privilege(c.oid, a.attnum, 'select'::text) AND ((c.relrowsecurity = false) OR (NOT row_security_active(c.oid))));
-pg_stats_ext| SELECT n.nspname AS schemaname,
- c.relname AS tablename,
- s.staname,
- s.stakeys AS attnums,
- length((s.standistinct)::bytea) AS ndistbytes,
- length((s.stadependencies)::bytea) AS depsbytes
- FROM ((pg_statistic_ext s
- JOIN pg_class c ON ((c.oid = s.starelid)))
- LEFT JOIN pg_namespace n ON ((n.oid = c.relnamespace)));
pg_tables| SELECT n.nspname AS schemaname,
c.relname AS tablename,
pg_get_userbyid(c.relowner) AS tableowner,