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 1l0uth-0005Ps-Ic for pgsql-hackers@arkaria.postgresql.org; Sat, 16 Jan 2021 23:22:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1l0utf-0003XR-Dg for pgsql-hackers@arkaria.postgresql.org; Sat, 16 Jan 2021 23:22:19 +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 1l0utf-0003XJ-1o for pgsql-hackers@lists.postgresql.org; Sat, 16 Jan 2021 23:22:19 +0000 Received: from mail-io1-xd34.google.com ([2607:f8b0:4864:20::d34]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1l0utX-0006er-HU for pgsql-hackers@postgresql.org; Sat, 16 Jan 2021 23:22:17 +0000 Received: by mail-io1-xd34.google.com with SMTP id n2so8479112iom.7 for ; Sat, 16 Jan 2021 15:22:10 -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=fIH6fCf9g14Tzv3iSQBj90/HQLAldUpkI5HrCduxk0Y=; b=sM6h4zHm8OGR2xV7Mis8h9+1+7m2ewoJUcd/y1hcZHcyhkJDElBtY9pNBb8UODeKUK r0ZyJ/mxUUcXe4+DqOZftPgq1b8hHX+TXpE71OgpwASOlMISD7uYj+oWjfvdfepZGLHN s7JgI4CjmKja2fHr+iFrtyYbUpdQt0xIYWRocq7acq0INtdpyqqrIARMj5q9jSnfybQt VW7MOuJCgmi6GNlIXT004p0N/k4KG+xC7KXGGkoWUTaYZg07LRaV/9Xf+6fRYGxgbmjY 8JUb/glE2ARxd1ZPC7zcLVMOn501yhmihyjbip9dPuSPYDXYvF0IO0fTDevrPcoJBx7E Tfcg== 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=fIH6fCf9g14Tzv3iSQBj90/HQLAldUpkI5HrCduxk0Y=; b=pSxvL+JAZ97qx0PG3qUB53Gf5T5ZuSJELmdfmhQNFweMV40u9Qi0C6ZrvqWHnYm1oT lC67hV2+YC/BTIDmp9SbGTsDFR9EZOlO04BwBpNRauq9c68c0kI/+RrqD7cOzVNkvhh9 qhDxGcwe7r0vYwjSJknK9RhZHpB+Iyx/f/PivZBf8FPe8ZiiX5lryYACP7vO4Ux/7WgP 18/HoM2mSBP9mifS3Qi9ZzoCnynZ3Sr5xNfskUIluVozxO94wGWZCTAOdefYpD8jTANf LrCw8dUiv2DGFEE0BrivvTgGFM+VQz06a+kN2z7aiiEbMR6VBO/0vj87157uXvFRoZsM B7+w== X-Gm-Message-State: AOAM5324vsggwjnFpA3M3Ms/qs0642c4Ql58Q3SqMNQF73DsATsD6cbI k3oeJsgtKJKnWpcbfNVYNXvzzw== X-Google-Smtp-Source: ABdhPJzGogBQilEgVuUUzVy0doZfqsdswBvzqwf26B08uMIzTiaGSSQym70ApILPWC7Gm6LKKbpbOg== X-Received: by 2002:a92:dc8c:: with SMTP id c12mr16289631iln.274.1610839330350; Sat, 16 Jan 2021 15:22:10 -0800 (PST) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 11sm7254689ilq.88.2021.01.16.15.22.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Jan 2021 15:22:09 -0800 (PST) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id CAC29800948; Sat, 16 Jan 2021 17:22:08 -0600 (CST) Date: Sat, 16 Jan 2021 17:22:08 -0600 From: Justin Pryzby To: Tomas Vondra Cc: Dean Rasheed , pgsql-hackers@postgresql.org Subject: Re: PoC/WIP: Extended statistics on expressions Message-ID: <20210116232208.GB8560@telsasoft.com> References: <329203a4-7cad-a0e3-d5a8-ce70872c8156@enterprisedb.com> <2567ae7e-e1dd-48b5-054d-ed6ff81c0335@enterprisedb.com> <20210108023537.GA19743@telsasoft.com> <5305f9cf-3927-06c4-cd5b-e46cbc58bc7f@enterprisedb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5305f9cf-3927-06c4-cd5b-e46cbc58bc7f@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 Sat, Jan 16, 2021 at 05:48:43PM +0100, Tomas Vondra wrote: > + > + expr text > + > + > + Expression the extended statistics is defined on > + Expression the extended statistics ARE defined on Or maybe say "on which the extended statistics are defined" > + > + The CREATE STATISTICS command has two basic forms. The > + simple variant allows to build statistics for a single expression, does .. ALLOWS BUILDING statistics for a single expression, AND does (or BUT does) > + Expression statistics are per-expression and are similar to creating an > + index on the expression, except that they avoid the overhead of the index. Maybe say "overhead of index maintenance" > + All functions and operators used in a statistics definition must be > + immutable, that is, their results must depend only on > + their arguments and never on any outside influence (such as > + the contents of another table or the current time). This restriction say "outside factor" or "external factor" > + results of those expression, and uses default estimates as illustrated > + by the first query. The planner also does not realize the value of the realize THAT > + second column fully defines the value of the other column, because date > + truncated to day still identifies the month. Then expression and > + ndistinct statistics are built on those two columns: I got an error doing this: CREATE TABLE t AS SELECT generate_series(1,9) AS i; CREATE STATISTICS s ON (i+1) ,(i+1+0) FROM t; ANALYZE t; SELECT i+1 FROM t GROUP BY 1; ERROR: corrupt MVNDistinct entry -- Justin