Re: list of extended statistics on psql

From: Tatsuro Yamada <tatsuro(dot)yamada(dot)tf(at)nttcom(dot)co(dot)jp>
To: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Julien Rouhaud <rjuju123(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: list of extended statistics on psql
Date: 2020-11-04 03:04:48
Message-ID: 831cda41-2299-51f7-12c3-9bf9d3328a58@nttcom.co.jp_1
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

> I addressed it, so I keep the size of extended stats with the unit.
>
> Changes:
> ========
>   - Use pg_size_pretty to show the size of extended stats by \dX+

I rebased the patch on the head and also added tab-completion.
Any feedback is welcome.

Preparing for tests:
===========
create table t1 (a int, b int);
create statistics stts_1 (dependencies) on a, b from t1;
create statistics stts_2 (dependencies, ndistinct) on a, b from t1;
create statistics stts_3 (dependencies, ndistinct, mcv) on a, b from t1;

create table t2 (a int, b int, c int);
create statistics stts_4 on b, c from t2;

create table hoge (col1 int, col2 int, col3 int);
create statistics stts_hoge on col1, col2, col3 from hoge;

create schema foo;
create schema yama;
create statistics foo.stts_foo on col1, col2 from hoge;
create statistics yama.stts_yama (ndistinct, mcv) on col1, col3 from hoge;

insert into t1 select i,i from generate_series(1,100) i;
analyze t1;

Result of \dX:
==============
postgres=# \dX
List of extended statistics
Schema | Name | Definition | N_distinct | Dependencies | Mcv
--------+-----------+----------------------------+------------+--------------+---------
foo | stts_foo | col1, col2 FROM hoge | defined | defined | defined
public | stts_1 | a, b FROM t1 | | built |
public | stts_2 | a, b FROM t1 | built | built |
public | stts_3 | a, b FROM t1 | built | built | built
public | stts_4 | b, c FROM t2 | defined | defined | defined
public | stts_hoge | col1, col2, col3 FROM hoge | defined | defined | defined
yama | stts_yama | col1, col3 FROM hoge | defined | | defined
(7 rows)

Result of \dX+:
===============
postgres=# \dX+
List of extended statistics
Schema | Name | Definition | N_distinct | Dependencies | Mcv | N_size | D_size | M_size
--------+-----------+----------------------------+------------+--------------+---------+----------+----------+------------
foo | stts_foo | col1, col2 FROM hoge | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
public | stts_1 | a, b FROM t1 | | built | | | 40 bytes |
public | stts_2 | a, b FROM t1 | built | built | | 13 bytes | 40 bytes |
public | stts_3 | a, b FROM t1 | built | built | built | 13 bytes | 40 bytes | 6126 bytes
public | stts_4 | b, c FROM t2 | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
public | stts_hoge | col1, col2, col3 FROM hoge | defined | defined | defined | 0 bytes | 0 bytes | 0 bytes
yama | stts_yama | col1, col3 FROM hoge | defined | | defined | 0 bytes | | 0 bytes
(7 rows)

Results of Tab-completion:
===============
postgres=# \dX <Tab>
foo. pg_toast. stts_2 stts_hoge
information_schema. public. stts_3 yama.
pg_catalog. stts_1 stts_4

postgres=# \dX+ <Tab>
foo. pg_toast. stts_2 stts_hoge
information_schema. public. stts_3 yama.
pg_catalog. stts_1 stts_4

Regards,
Tatsuro Yamada

Attachment Content-Type Size
add_list_extended_stats_for_psql_by_dX_and_dXplus_r7.patch text/plain 13.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-11-04 03:19:04 Re: Parallel INSERT (INTO ... SELECT ...)
Previous Message k.jamison@fujitsu.com 2020-11-04 02:58:27 RE: [Patch] Optimize dropping of relation buffers using dlist