Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i30iZ-0008SP-Pz for pgsql-docs@arkaria.postgresql.org; Wed, 28 Aug 2019 16:22:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i30iY-0000UC-Kv for pgsql-docs@arkaria.postgresql.org; Wed, 28 Aug 2019 16:22:42 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i30iY-0000U5-6h for pgsql-docs@lists.postgresql.org; Wed, 28 Aug 2019 16:22:42 +0000 Received: from momjian.us ([72.94.173.45]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1i30iV-0002DE-UA for pgsql-docs@postgresql.org; Wed, 28 Aug 2019 16:22:41 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1i30iU-0002M5-Mk; Wed, 28 Aug 2019 12:22:38 -0400 Date: Wed, 28 Aug 2019 12:22:38 -0400 From: Bruce Momjian To: PostgreSQL-documentation Cc: Tomas Vondra Subject: Most-common value docs in PG 12 Message-ID: <20190828162238.GA8360@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 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 +