Re: PoC/WIP: Extended statistics on expressions

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: PoC/WIP: Extended statistics on expressions
Date: 2020-11-23 02:26:04
Message-ID: 20201123022604.GD24052@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Nov 22, 2020 at 08:03:51PM +0100, Tomas Vondra wrote:
> attached is a significantly improved version of the patch, allowing
> defining extended statistics on expressions. This fixes most of the
> problems in the previous WIP version and AFAICS it does pass all
> regression tests (including under valgrind). There's a bunch of FIXMEs
> and a couple loose ends, but overall I think it's ready for reviews.

I was looking at the previous patch, so now read this one instead, and attach
some proposed fixes.

+ * This matters especially for * expensive expressions, of course.

+ The expression can refer only to columns of the underlying table, but
+ it can use all columns, not just the ones the statistics is defined
+ on.

I don't know what these are trying to say?

+ errmsg("statistics expressions and predicates can refer only to the table being indexed")));
+ * partial-index predicates. Create it in the per-index context to be

I think these are copied and shouldn't mention "indexes" or "predicates". Or
should statistics support predicates, too ?

Idea: if a user specifies no stakinds, and there's no expression specified,
then you automatically build everything except for expressional stats. But if
they specify only one statistics "column", it gives an error. If that's a
non-simple column reference, should that instead build *only* expressional
stats (possibly with a NOTICE, since the user might be intending to make MV
stats).

I think pg_stats_ext should allow inspecting the pg_statistic data in
pg_statistic_ext_data.stxdexprs. I guess array_agg() should be ordered by
something, so maybe it should use ORDINALITY (?)

I hacked more on bootstrap.c so included that here.

--
Justin

Attachment Content-Type Size
0001-bootstrap-convert-Typ-to-a-List.patch text/x-diff 3.7 KB
0002-Allow-composite-types-in-bootstrap.patch text/x-diff 1.4 KB
0003-Extended-statistics-on-expressions.patch text/x-diff 209.7 KB
0004-Fix-silly-errors.patch text/x-diff 2.6 KB
0005-Small-language-fixen.patch text/x-diff 4.1 KB
0006-Some-cleanup.patch text/x-diff 10.9 KB
0007-WIP-Update-pg_stats_ext-for-expressional-stats-incom.patch text/x-diff 12.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message tsunakawa.takay@fujitsu.com 2020-11-23 02:49:59 RE: [POC] Fast COPY FROM command for the table with foreign partitions
Previous Message tsunakawa.takay@fujitsu.com 2020-11-23 02:17:14 RE: POC: postgres_fdw insert batching