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 1i3qJU-0002cW-8X for pgsql-docs@arkaria.postgresql.org; Fri, 30 Aug 2019 23:28:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1i3qJS-0004v6-8g for pgsql-docs@arkaria.postgresql.org; Fri, 30 Aug 2019 23:28:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3qJS-0004uz-1Y for pgsql-docs@lists.postgresql.org; Fri, 30 Aug 2019 23:28:14 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1i3qJK-0003vw-J1 for pgsql-docs@postgresql.org; Fri, 30 Aug 2019 23:28:13 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1i3qJI-0006dN-5j; Fri, 30 Aug 2019 19:28:04 -0400 Date: Fri, 30 Aug 2019 19:28:04 -0400 From: Bruce Momjian To: Tomas Vondra Cc: PostgreSQL-documentation Subject: Re: Most-common value docs in PG 12 Message-ID: <20190830232804.GA10645@momjian.us> References: <20190828162238.GA8360@momjian.us> <20190828182541.zuexunho3hgb7vlw@development> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="wac7ysb48OaltWcw" Content-Disposition: inline In-Reply-To: <20190828182541.zuexunho3hgb7vlw@development> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --wac7ysb48OaltWcw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Aug 28, 2019 at 08:25:41PM +0200, Tomas Vondra wrote: > On Wed, Aug 28, 2019 at 12:22:38PM -0400, Bruce Momjian wrote: > > If this is so, why don't we show the CREATE STATISTICS example as > > city/state, and not state/city? > > Yes, we deduplicate the attributes and store them sorted by attnum. I'm > not sure it makes sense to change the example to match this order, which > is mostly an implementation detail, though. It might be better to point > out the order may not exactly match CREATE STATISTICS, and point users to > what e.g. "\d" shows (because that will show the order as stored in the > system catalog). OK, how is this patch? I didn't mention psql since I think everyone expects psql to show all information about tables and indexes. -- 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 + --wac7ysb48OaltWcw Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="mcv.diff" diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml index 8e165832b3..a645127e69 100644 --- a/doc/src/sgml/perform.sgml +++ b/doc/src/sgml/perform.sgml @@ -1172,7 +1172,7 @@ WHERE tablename = 'road'; Here is an example of collecting functional-dependency statistics: -CREATE STATISTICS stts (dependencies) ON zip, city FROM zipcodes; +CREATE STATISTICS stts (dependencies) ON city, zip FROM zipcodes; ANALYZE zipcodes; @@ -1262,7 +1262,7 @@ SELECT * FROM zipcodes WHERE city = 'San Francisco' AND zip = '90210'; Continuing the previous example, the n-distinct counts in a table of ZIP codes might look like the following: -CREATE STATISTICS stts2 (ndistinct) ON zip, state, city FROM zipcodes; +CREATE STATISTICS stts2 (ndistinct) ON city, state, zip FROM zipcodes; ANALYZE zipcodes; @@ -1317,7 +1317,7 @@ nd | {"1, 2": 33178, "1, 5": 33178, "2, 5": 27435, "1, 2, 5": 33178} a function is required for inspection of MCV contents): -CREATE STATISTICS stts3 (mcv) ON state, city FROM zipcodes; +CREATE STATISTICS stts3 (mcv) ON city, state FROM zipcodes; ANALYZE zipcodes; diff --git a/doc/src/sgml/ref/create_statistics.sgml b/doc/src/sgml/ref/create_statistics.sgml index ec23a154d6..5b583aacb4 100644 --- a/doc/src/sgml/ref/create_statistics.sgml +++ b/doc/src/sgml/ref/create_statistics.sgml @@ -98,7 +98,8 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na The name of a table column to be covered by the computed statistics. - At least two column names must be given. + At least two column names must be given; the order of the column names + is insignificant. --wac7ysb48OaltWcw--