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-02-18T01:31:44Z
Lists: pgsql-hackers
Attachments
- 0001-bootstrap-convert-Typ-to-a-List-20210218.patch (text/x-patch)
Hi, Attached is a rebased patch series, merging the changes from the last review into the 0003 patch, and with a WIP patch 0004 reworking the tracking of expressions (to address the inefficiency due to relying on MaxHeapAttributeNumber). The 0004 passes is very much an experimental patch with a lot of ad hoc changes. It passes make check, but it definitely needs much more work, cleanup and testing. At this point it's more a demonstration of what would be needed to rework it like this. The main change is that instead of handling expressions by assigning them attnums above MaxHeapAttributeNumber, we assign them system-like attnums, i.e. negative ones. So the first one gets -1, the second one -2, etc. And then we shift all attnums above 0, to allow using the bitmapset as before. Overall, this works, but the shifting is kinda pointless - it allows us to build a bitmapset, but it's mostly useless because it depends on how many expressions are in the statistics definition. So we can't compare or combine bitmapsets for different statistics, and (more importantly) we can't easily compare bitmapset on attnums from clauses. Using MaxHeapAttributeNumber allowed using the bitmapsets at least for regular attributes. Not sure if that's a major advantage, outweighing wasting some space. I wonder if we should just ditch the bitmapsets, and just use simple arrays of attnums. I don't think we expect too many elements here, especially when dealing with individual statistics. So now we're just building and rebuilding the bitmapsets ... seems pointless. One thing I'd like to improve (independently of what we do with the bitmapsets) is getting rid of the distinction between attributes and expressions when building the statistics - currently all the various places have to care about whether the item is attribute or expression, and look either into the tuple or array of pre-calculated value, do various shifts to get the indexes, etc. That's quite tedious, and I've made a lot of errors in that (and I'm sure there are more). So IMO we should simplify this by replacing this with something containing values for both attributes and expressions, handling it in a unified way. 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