Re: list of extended statistics on psql

Поиск
Список
Период
Сортировка
От Julien Rouhaud
Тема Re: list of extended statistics on psql
Дата
Msg-id CAOBaU_YAwz99psuJ6WJWk6k4H-K7BH61NbCTqL3o4Zhg2=D7Bw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: list of extended statistics on psql  (Pavel Stehule <pavel.stehule@gmail.com>)
Ответы Re: list of extended statistics on psql  (Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp>)
Список pgsql-hackers
On Mon, Aug 24, 2020 at 6:13 AM Pavel Stehule <pavel.stehule@gmail.com> wrote:
>
> po 24. 8. 2020 v 5:23 odesílatel Tatsuro Yamada <tatsuro.yamada.tf@nttcom.co.jp> napsal:
>>
>> Hi!
>>
>> I created a POC patch that allows showing a list of extended statistics by
>> "\dz" command on psql. I believe this feature helps DBA and users who
>> would like to know all extended statistics easily. :-D
>>
>> I have not a strong opinion to assign "\dz". I prefer "\dx" or "\de*"
>> than "\dz" but they were already assigned. Therefore I used "\dz"
>> instead of them.
>>
>> Please find the attached patch.
>> Any comments are welcome!
>>
>> For Example:
>> =======================
>> CREATE TABLE t1 (a INT, b INT);
>> CREATE STATISTICS stts1 (dependencies) ON a, b FROM t1;
>> CREATE STATISTICS stts2 (dependencies, ndistinct) ON a, b FROM t1;
>> CREATE STATISTICS stts3 (dependencies, ndistinct, mcv) ON a, b FROM t1;
>> ANALYZE t1;
>>
>> CREATE TABLE t2 (a INT, b INT, c INT);
>> CREATE STATISTICS stts4 ON b, c FROM t2;
>> ANALYZE t2;
>>
>> postgres=# \dz
>>                      List of extended statistics
>>   Schema | Table | Name  | Columns | Ndistinct | Dependencies | MCV
>> --------+-------+-------+---------+-----------+--------------+-----
>>   public | t1    | stts1 | a, b    | f         | t            | f
>>   public | t1    | stts2 | a, b    | t         | t            | f
>>   public | t1    | stts3 | a, b    | t         | t            | t
>>   public | t2    | stts4 | b, c    | t         | t            | t
>> (4 rows)
>>
>> postgres=# \?
>> ...
>>    \dy     [PATTERN]      list event triggers
>>    \dz     [PATTERN]      list extended statistics
>>    \l[+]   [PATTERN]      list databases
>> ...
>> =======================
>>
>> For now, I haven't written a document and regression test for that.
>> I'll create it later.
>
>
> +1 good idea

+1 that's a good idea.  Please add it to the next commitfest!

You have a typo:

+    if (pset.sversion < 10000)
+    {
+        char        sverbuf[32];
+
+        pg_log_error("The server (version %s) does not support
extended statistics.",
+                     formatPGVersionNumber(pset.sversion, false,
+                                           sverbuf, sizeof(sverbuf)));
+        return true;
+    }

the version test is missing a 0, the feature looks otherwise ok.

How about using \dX rather than \dz?



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Fujii Masao
Дата:
Сообщение: Re: Creating a function for exposing memory usage of backend process
Следующее
От: Dilip Kumar
Дата:
Сообщение: Re: Re: [HACKERS] Custom compression methods