Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1HRE-0004PG-LV for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jan 2021 23:26:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l1HRC-0002Rb-GF for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jan 2021 23:26:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l1HRC-0002RO-9Q for pgsql-hackers@lists.postgresql.org; Sun, 17 Jan 2021 23:26:26 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l1HR9-0000hw-B2 for pgsql-hackers@postgresql.org; Sun, 17 Jan 2021 23:26:24 +0000 Received: by mail-ej1-x629.google.com with SMTP id g12so21190696ejf.8 for ; Sun, 17 Jan 2021 15:26:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=kjjoOjcSNrifOUpJTm5Kq0uOtD98McNo2mx9mRh+pKQ=; b=YZ9rHLH5MnuwMDtkSnLFZFiQribbC1kIEMOn47O3UThbXDiR00qU1gHeUIOy7XKpMt WTjt0zw15SuozhI4tacoOtIFp+AJNN8XNDcYzq7vmO16awD0dl9w+lgWzt2LWrfQrWpO JqDOfP6is3XFFFawu9cYLiN7Ci89GzVyXGoN9TH6F0DHbCvtSqYG9P4eTKibU5vaHj/R tK4aFt5t+kwdkkSypnYn2ycCwyON0p5L5wBnydUoBJa82MxQ8iOJK0QnCpZ8zQ5oxLTW 7rYo6sxa/9xupeldAC7H3nlYB6iFGBIu/syckvLVP7BJb6AspVAvBbwxKp3MnwbsZ+zK b+iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=kjjoOjcSNrifOUpJTm5Kq0uOtD98McNo2mx9mRh+pKQ=; b=MXI+mn3V+d9yp5aAuwGcCASY8YMnthldgBf/DG9bi36hLRQ33V6mT63JkBWVAkDSH9 w7slSdnjQXfBUF6lnQlrsE4KEXX2sQ4AYSi008fOgK4WBDyX1RbZHMlRj8+fXKvyPRUo /GzRJQAa9petE1+1WJukSV7wA4QBcPn6qHENIbxF4lMrJptgHM6Qd2LnXZrnbuKhl/u8 rN5Vza2mhd5DHhzc7H8GXBF3R0h6UJT3A8TYqd4rhjQH47sv7qIOVDKg1nNLQNJzNQ/h IzILWrczNpay9Tb6LjtpLN3IYigqix/dvAurTvx5duZo/Ypw8qkyCZLww33CKbpXm6kK Bplw== X-Gm-Message-State: AOAM531hj4BJHHf9V969a/1fIu603pLIAf4TcnuSFKtAsYdVasM5SURB YjijavSrxUfBFy86G+8PBTMvuhZVbej1TgBHY3ptd/isVKE7o6nmAMptO+JAAlipBZ6Voq8+zOM f9CYdvvb5j3Fg33ZcgC06UYYkNMHzCqq1svxdAF+HEu3zS6/GtaE5iuBhcRo0cw2kwOtGk3ruTs CM5YKK1GO0G+LJyuxu9NPh2g/7m8095fkkTBfmW8D6HNWOPNt7And2+NE9ObNe3rolj6R841rvQ vEIoinO3phzs0NJvbig7TFzu7/VGwK9FFW79A== X-Google-Smtp-Source: ABdhPJyYvZHgScXG5AKf1VrBK3kakuUO1mJygkBY9meEW5UFRjR9vwNrlT7tZywfKXfHR2tlOQcU6g== X-Received: by 2002:a17:906:3881:: with SMTP id q1mr15949836ejd.490.1610925981371; Sun, 17 Jan 2021 15:26:21 -0800 (PST) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id o13sm9705018edr.94.2021.01.17.15.26.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 17 Jan 2021 15:26:20 -0800 (PST) Subject: Re: PoC/WIP: Extended statistics on expressions To: Justin Pryzby Cc: Dean Rasheed , pgsql-hackers@postgresql.org References: <2567ae7e-e1dd-48b5-054d-ed6ff81c0335@enterprisedb.com> <20210108023537.GA19743@telsasoft.com> <5305f9cf-3927-06c4-cd5b-e46cbc58bc7f@enterprisedb.com> <20210116232208.GB8560@telsasoft.com> <2f2a3b3b-93e4-723f-144e-bc21f10d6b61@enterprisedb.com> <20210117052954.GC8560@telsasoft.com> From: Tomas Vondra Message-ID: <131b0d63-5ab8-6fa4-fb77-cd0bc23d5e23@enterprisedb.com> Date: Mon, 18 Jan 2021 00:26:17 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210117052954.GC8560@telsasoft.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/17/21 6:29 AM, Justin Pryzby wrote: > On Sun, Jan 17, 2021 at 01:23:39AM +0100, Tomas Vondra wrote: >> diff --git a/doc/src/sgml/ref/create_statistics.sgml b/doc/src/sgml/ref/create_statistics.sgml >> index 4363be50c3..5b8eb8d248 100644 >> --- a/doc/src/sgml/ref/create_statistics.sgml >> +++ b/doc/src/sgml/ref/create_statistics.sgml >> @@ -21,9 +21,13 @@ PostgreSQL documentation >> >> >> >> +CREATE STATISTICS [ IF NOT EXISTS ] statistics_name >> + ON ( expression ) >> + FROM table_name > >> CREATE STATISTICS [ IF NOT EXISTS ] statistics_name >> [ ( statistics_kind [, ... ] ) ] >> - ON column_name, column_name [, ...] >> + ON { column_name | ( expression ) } [, ...] >> FROM table_name >> > > I think this part is wrong, since it's not possible to specify a single column > in form#2. > > If I'm right, the current way is: > > - form#1 allows expression statistics of a single expression, and doesn't > allow specifying "kinds"; > > - form#2 allows specifying "kinds", but always computes expression statistics, > and requires multiple columns/expressions. > > So it'd need to be column_name|expression, column_name|expression [,...] > Strictly speaking you're probably correct - there should be at least two elements. But I'm somewhat hesitant about making this more complex, because it'll be harder to understand. >> @@ -39,6 +43,16 @@ CREATE STATISTICS [ IF NOT EXISTS ] statistics_na >> database and will be owned by the user issuing the command. >> >> >> + >> + The CREATE STATISTICS command has two basic forms. The >> + simple variant allows building statistics for a single expression, does >> + not allow specifying any statistics kinds and provides benefits similar >> + to an expression index. The full variant allows defining statistics objects >> + on multiple columns and expressions, and selecting which statistics kinds will >> + be built. The per-expression statistics are built automatically when there >> + is at least one expression. >> + > >> + >> + expression >> + >> + >> + The expression to be covered by the computed statistics. In this case >> + only a single expression is required, in which case only the expression >> + statistics kind is allowed. The order of expressions is insignificant. > > I think this part is wrong now ? > I guess there's no user-facing expression "kind" left in the CREATE command. > I guess "in which case" means "if only one expr is specified". > "expression" could be either form#1 or form#2. > > Maybe it should just say: >> + An expression to be covered by the computed statistics. > > Maybe somewhere else, say: >> In the second form of the command, the order of expressions is insignificant. > Yeah, this is a leftover from when there was "expressions" kind. I'll reword this a bit. thanks -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company