Re: PATCH: add support for IN and @> in functional-dependency statistics use
Tomas Vondra <tomas.vondra@2ndquadrant.com>
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Pierre Ducroquet <p.psql@pinaraf.info>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2020-03-05T02:34:14Z
Lists: pgsql-hackers
Attachments
Hi Pierre, I've looked at this patch series, hoping to get it close to committable. Here is a somewhat improved version of the patch series, split into 5 pieces. The first 4 parts are about applying functional dependencies to ScalarArrayOpExpr clauses. The last part is about doing the same thing for MCV lists, so it seemed fine to post it here. 0001 is the patch you posted back in October 0002 simplifies the handling logic a bit, because ScalarArrayOpExpr can only have form (Var op Const) but not (Const op Var). 0003 fixes what I think is a bug - ScalarArrayOpExpr can represent three different cases: * Var op ANY () * Var IN () -- special case of ANY * Var op ALL () I don't think functional dependencies can handle the ALL case, we need to reject it by checking the useOr flag. 0004 adds queries to the stats_ext test suite, to test all of this (some of the cases illustrate the need for 0003, I think) 0005 allows estimation of ScalarArrayOpExpr by MCV lists, including regression tests etc. Will you have time to look at this, particularly 0001-0004, but maybe even the 0005 part? As for the second part of your patch (the one allowing estimation of array containment queries), I still think that's not something we can reasonably do without also building statistics on elements (which is what we have in pg_stats but not pg_stats_ext). regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Commits
-
Prevent functional dependency estimates from exceeding column estimates.
- 87779aa47463 13.0 landed
-
Recognize some OR clauses as compatible with functional dependencies
- ccaa3569f587 13.0 landed
-
Use multi-variate MCV lists to estimate ScalarArrayOpExpr
- e83daa7e331e 13.0 landed
-
Use functional dependencies to estimate ScalarArrayOpExpr
- 8f321bd16cdb 13.0 landed