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: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Pierre Ducroquet <p.psql@pinaraf.info>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-03-14T18:45:35Z
Lists: pgsql-hackers
Attachments
- estimate-OR-similar-to-IN-clauses.patch (text/plain) patch
Hi, I realized there's one more thing that probably needs discussing. Essentially, these two clause types are the same: a IN (1, 2, 3) (a = 1 OR a = 2 OR a = 3) but with 8f321bd1 we only recognize the first one as compatible with functional dependencies. It was always the case that we estimated those two clauses a bit differently, but the differences were usually small. But now that we recognize IN as compatible with dependencies, the difference may be much larger, which bugs me a bit ... So I wonder if we should recognize the special form of an OR clause, with all Vars referencing to the same attribute etc. and treat this as supported by functional dependencies - the attached patch does that. MCV lists there's already no difference because OR clauses are supported. The question is whether we want to do this, and whether we should also teach the per-column estimates to recognize this special case of IN clause. That would allow producing exactly the same estimates even with functional dependencies - recognizing the OR clause as supported gets us only half-way there, because we still use estimates for each clause (and those will be slightly different). 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