Most-common value docs in PG 12 - Mailing list pgsql-docs

From Bruce Momjian
Subject Most-common value docs in PG 12
Date
Msg-id 20190828162238.GA8360@momjian.us
Whole thread Raw
Responses Re: Most-common value docs in PG 12  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
List pgsql-docs
Our docs for most-common values in PG 12 has:

-->    CREATE STATISTICS stts3 (mcv) ON state, city FROM zipcodes;
    
    ANALYZE zipcodes;
    
    SELECT m.* FROM pg_statistic_ext join pg_statistic_ext_data on (oid = stxoid),
                    pg_mcv_list_items(stxdmcv) m WHERE stxname = 'stts3';
    
     index |         values         | nulls | frequency | base_frequency
    -------+------------------------+-------+-----------+----------------
-->         0 | {Washington, DC}       | {f,f} |  0.003467 |        2.7e-05
         1 | {Apo, AE}              | {f,f} |  0.003067 |        1.9e-05
         2 | {Houston, TX}          | {f,f} |  0.002167 |       0.000133
         3 | {El Paso, TX}          | {f,f} |     0.002 |       0.000113

It seems pg_mcv_list_items() reports the column names in the order they
appear in the table, not in the order they appear in the CREATE
STATISTICS statement.  Same for psql \d:

    \d zipcodes
                 Table "public.zipcodes"
     Column  | Type | Collation | Nullable | Default
    ---------+------+-----------+----------+---------
     city    | text |           |          |
     state   | text |           |          |
     zipcode | text |           |          |
    Statistics objects:
-->        "public"."stts3" (mcv) ON city, state FROM zipcodes


If this is so, why don't we show the CREATE STATISTICS example as
city/state, and not state/city?

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +



pgsql-docs by date:

Previous
From: PG Doc comments form
Date:
Subject: Truncate statement-level trigger behaviour
Next
From: PG Doc comments form
Date:
Subject: installation