Re: PoC/WIP: Extended statistics on expressions
Tomas Vondra <tomas.vondra@enterprisedb.com>
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Justin Pryzby <pryzby@telsasoft.com>,
PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2021-03-24T00:51:09Z
Lists: pgsql-hackers
Attachments
- 0001-Extended-statistics-on-expressions-20210324.patch (text/x-patch)
Hi, I've pushed the first two parts, dealing with composite types during bootstrap. I've decided to commit both, including the array->list conversion, as that makes the reloads simpler. I've made two tweaks: 1) I've renamed the function to reload_typ_list, which I think is better (and it used to be reload_typ_array). 2) I've removed the did_reread assert. It'd allow just a single reload, which blocks recursive composite types - seems unnecessary, although we don't need that now. I think we can't have infinite recursion, because we can only load types from already defined catalogs (so no cycles). I've rebased and cleaned up the main part of the patch. There's a bunch of comments slightly reworded / cleaned up, etc. The more significant changes are: 1) The explanation of the example added to create_statistics.sgml was somewhat wrong, so I corrected that. 2) I've renamed StatBuildData to StatsBuildData. 3) I've resolved the FIXMEs in examine_expression. We don't need to do anything special about the collation, because unlike indexes it's not possible to specify "collate" for the attributes. It's possible to do thatin the expression, but exprCollation handles that. For statistics target, we simply use the value determined for the statistics itself. There's no way to specify that for expressions. 4) I've updated the comments about ndistinct estimates in selfuncs.c, because some of it was a bit wrong/misleading - per the discussion we had about matching stats to expressions. 5) I've also tweaked the add_unique_group_expr so that we don't have to run examine_variable() repeatedly if we already have it. 6) Resolved the FIXME about acl_ok in examine_variable. Instead of just setting it to 'true' it now mimics what we do for indexes. I think it's correct, but this is probably worth a review. 7) psql now prints expressions only for (version > 14). I've considered tweaking the existing block, but that was quite incomprehensible so I just made a modified copy. I think this is 99.999% ready to be pushed, so barring objections I'll do that in a day or two. The part 0003 is a small tweak I'll consider, preferring exact matches of expressions over Var matches. It's not a clear win (but what is, in a greedy algorithm), but it does improve one of the regression tests. Minor change, though. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Commits
-
Disallow extended statistics on system columns
- 66061077155d 14.0 landed
- c9eeef2a15c0 15.0 landed
-
Identify simple column references in extended statistics
- 50ba70a957f9 14.0 landed
- 537ca68dbb24 15.0 landed
-
Don't print extra parens around expressions in extended stats
- 4d1816ec26e8 14.0 landed
- 13380e147649 15.0 landed
-
Change position of field "transformed" in struct CreateStatsStmt.
- 13a1ca160dcf 14.0 landed
-
Add transformed flag to nodes/*funcs.c for CREATE STATISTICS
- d57ecebd128c 14.0 landed
-
Stabilize stats_ext test with other collations
- 2a058e938c73 14.0 landed
-
Extended statistics on expressions
- a4d75c86bf15 14.0 landed
-
Reduce duration of stats_ext regression tests
- 98376c18f12e 14.0 landed
-
Allow composite types in catalog bootstrap
- 79f6a942bdb9 14.0 landed
-
Convert Typ from array to list in bootstrap
- e1a5e65703ce 14.0 landed
-
Disallow CREATE STATISTICS on system catalogs
- c22539756ee5 10.16 landed
- f52db969440b 11.11 landed
- 943a113bcb6f 12.6 landed
- d26d4c717dbf 13.2 landed
- c9a0dc34865f 14.0 landed