From: Alvaro Herrera Date: Thu, 13 Apr 2017 14:35:22 +0000 (-0300) Subject: Remove pg_stats_ext view X-Git-Tag: REL_10_BETA1~280 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d5facfd9ab66c819ed583b2614b0560405a6aa2;p=postgresql Remove pg_stats_ext view It was created as equivalent of pg_stats, but since the code underlying pg_statistic_ext is more convenient than the one for pg_statistic, pg_stats_ext is no longer useful. Author: David Rowley Reviewed-by: Tomas Vondra Discussion: https://postgr.es/m/CAKJS1f9zAkPUf9nQrqpFBAsrOHvb5eYa2FVNsmCJy1wegcO_TQ@mail.gmail.com --- diff --git a/doc/src/sgml/planstats.sgml b/doc/src/sgml/planstats.sgml index f8af42f394..a4f91c737a 100644 --- a/doc/src/sgml/planstats.sgml +++ b/doc/src/sgml/planstats.sgml @@ -520,17 +520,15 @@ EXPLAIN ANALYZE SELECT * FROM t WHERE a = 1 AND b = 1; Similarly to per-column statistics, extended statistics are stored in - a system catalog called pg_statistic_ext, but - there is also a more convenient view pg_stats_ext. + a system catalog called pg_statistic_ext. To inspect the statistics s1 defined above, you may do this: -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) diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 500221ae77..421d51db47 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -186,17 +186,6 @@ CREATE OR REPLACE VIEW pg_sequences AS 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, diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index b2779d9698..409692d695 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2188,15 +2188,6 @@ pg_stats| SELECT n.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,