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 1l10da-0000jL-CZ for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jan 2021 05:30:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l10dZ-00039Y-1M for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Jan 2021 05:30:05 +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 1l10dY-00039R-Mr for pgsql-hackers@lists.postgresql.org; Sun, 17 Jan 2021 05:30:04 +0000 Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l10dR-0000uM-NM for pgsql-hackers@postgresql.org; Sun, 17 Jan 2021 05:30:03 +0000 Received: by mail-io1-xd32.google.com with SMTP id z5so26469394iob.11 for ; Sat, 16 Jan 2021 21:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=6s8DZlhGlGzgH+M37ervB7sgApLMnB+fWszQAXXTzxY=; b=YGVAP0QC3PJlu9T32/r+dJ53fsrOp/BYmzBm5w4sMnonLV8H8TqdwfrglYxysN7UvD TaPyzsgOddU27VlsKEOGf40bskJxowXn1/tTtOlYKp7pJI5mpzxvBcafyNDADwy2KXEg vWmIihKeTgkE7/yXHql8j6syCNShi+JCv8lYFje0j+yt2+wQQPxiWx9kfH//BzlPV4SC 1mB69+uVnhpStggoYWvzZDHkEGK0jZF2AfgPNF3W853RgJW0BoQFrHwWBj0F87evRDho KyK9jhEbXWZGIB6h94ZAE69855MqN3hqwGGU93SzKZDlib81Cb0OQD1aIdmaBwvCmBkd ypng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=6s8DZlhGlGzgH+M37ervB7sgApLMnB+fWszQAXXTzxY=; b=E1hb/zAO2HeuigkQO+ng+Xip9VozOmShh1AzcoTg+QuxthpENQ0XlW42I8NtYAwSp7 fzRJus4zF6JIDbOk17UkQakl+5Kp1FaJp+mpiC5qT2PmISrUWylb29al7jP44UebRdFF yzNmw3GWU9jXfGDxzF8PcCK0VjOJEoZSMW7DNQiKBP9+631AtWS2zuTUJ2xziWhmf93Y Dt+ZwkugzTq2mVZkvajIxJG8S9ot7AWJ6D+nMVbM20cVFNQG9KDwJ38op/9ZnNcZfY0Z hKMPniPa1optEUqJTQCr5kK+0izls5hNszfj9B2w2762PKpGwqfOeO0Ivxpkp+tSThq4 8exw== X-Gm-Message-State: AOAM5308zeGQvipiQWqAcON3JtKDfSnWAhsi+HoYEhTWQOq7Qo0tfRGb oSn/47wXnnEf7F7mvXVXQk5IjA== X-Google-Smtp-Source: ABdhPJwfYVUtV5VGivOGTy81PDYpX1JBKGWuE9MAtCQuM06w/84lm+R33a43wy+EJRwDGRR9kRBTKw== X-Received: by 2002:a05:6e02:1a04:: with SMTP id s4mr17306846ild.266.1610861396226; Sat, 16 Jan 2021 21:29:56 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id h6sm2305288iog.47.2021.01.16.21.29.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jan 2021 21:29:55 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 59E948007F8; Sat, 16 Jan 2021 23:29:54 -0600 (CST) Date: Sat, 16 Jan 2021 23:29:54 -0600 From: Justin Pryzby To: Tomas Vondra Cc: Dean Rasheed , pgsql-hackers@postgresql.org Subject: Re: PoC/WIP: Extended statistics on expressions Message-ID: <20210117052954.GC8560@telsasoft.com> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2f2a3b3b-93e4-723f-144e-bc21f10d6b61@enterprisedb.com> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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 [,...] > @@ -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. -- Justin