Re: list of extended statistics on psql - Mailing list pgsql-hackers

From Tatsuro Yamada
Subject Re: list of extended statistics on psql
Date
Msg-id ad31aaac-85eb-dfed-28e6-afc0f23c7381@nttcom.co.jp_1
Whole thread Raw
In response to Re: list of extended statistics on psql  (Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>)
List pgsql-hackers
Hi,

> The above query is so simple so that we would better to use the following query:
> 
> # This query works on PG10 or later
> SELECT
>      es.stxnamespace::pg_catalog.regnamespace::text AS "Schema",
>      es.stxname AS "Name",
>      pg_catalog.format('%s FROM %s',
>          (SELECT pg_catalog.string_agg(pg_catalog.quote_ident(a.attname),', ')
>           FROM pg_catalog.unnest(es.stxkeys) s(attnum)
>           JOIN pg_catalog.pg_attribute a
>           ON (es.stxrelid = a.attrelid
>           AND a.attnum = s.attnum
>           AND NOT a.attisdropped)),
>      es.stxrelid::regclass) AS "Definition",
>      CASE WHEN 'd' = any(es.stxkind) THEN 'defined'
>      END AS "Ndistinct",
>      CASE WHEN 'f' = any(es.stxkind) THEN 'defined'
>      END AS "Dependencies",
>      CASE WHEN 'm' = any(es.stxkind) THEN 'defined'
>      END AS "MCV"
> FROM pg_catalog.pg_statistic_ext es
> ORDER BY 1, 2;
> 
>   Schema |    Name    |    Definition    | Ndistinct | Dependencies | Dependencies
> --------+------------+------------------+-----------+--------------+--------------
>   public | hoge1_ext  | a, b FROM hoge1  | defined   | defined      | defined
>   public | hoge_t_ext | a, b FROM hoge_t | defined   | defined      | defined
> (2 rows)
> 
> 
> I'm going to create the WIP patch to use the above query.
> Any comments welcome. :-D


Attached patch is WIP patch.

The changes are:
   - Use pg_statistic_ext only
   - Remove these statuses: "required" and "built"
   - Add new status: "defined"
   - Remove the size columns
   - Fix document

I'll create and send the regression test on the next patch if there is
no objection. Is it Okay?

Regards,
Tatsuro Yamada


Attachment

pgsql-hackers by date:

Previous
From: Zhihong Yu
Date:
Subject: Re: simplifying foreign key/RI checks
Next
From: Dilip Kumar
Date:
Subject: Re: Is Recovery actually paused?