postgresql/src
Tomas Vondra ccaa3569f5 Recognize some OR clauses as compatible with functional dependencies
Since commit 8f321bd16c functional dependencies can handle IN clauses,
which however introduced a possible (and surprising) inconsistency,
because IN clauses may be expressed as an OR clause, which are still
considered incompatible. For example

  a IN (1, 2, 3)

may be rewritten as

  (a = 1 OR a = 2 OR a = 3)

The IN clause will work fine with functional dependencies, but the OR
clause will force the estimation to fall back to plain per-column
estimates, possibly introducing significant estimation errors.

This commit recognizes OR clauses equivalent to an IN clause (when all
arugments are compatible and reference the same attribute) as a special
case, compatible with functional dependencies. This allows applying
functional dependencies, just like for IN clauses.

This does not eliminate the difference in estimating the clause itself,
i.e. IN clause and OR clause still use different formulas. It would be
possible to change that (for these special OR clauses), but that's not
really about extended statistics - it was always like this. Moreover the
errors are usually much smaller compared to ignoring dependencies.

Author: Tomas Vondra
Reviewed-by: Dean Rasheed
Discussion: https://www.postgresql.org/message-id/flat/13902317.Eha0YfKkKy%40pierred-pdoc
2020-03-18 16:41:49 +01:00
..
backend Recognize some OR clauses as compatible with functional dependencies 2020-03-18 16:41:49 +01:00
bin Plug memory leak 2020-03-16 16:27:13 -03:00
common Allow Unicode escapes in any server encoding, not only UTF-8. 2020-03-06 14:17:43 -05:00
fe_utils Fix bug in pg_basebackup -F plain -R. 2020-02-12 09:08:22 +09:00
include Assert that we don't acquire a heavyweight lock on another object after 2020-03-18 07:20:17 +05:30
interfaces Fix issues around .pgpass file. 2020-03-05 13:00:38 +09:00
makefiles
pl Remove utils/acl.h from catalog/objectaddress.h 2020-03-10 10:27:00 +01:00
port Remove win32ver.rc from version_stamp.pl 2020-03-10 11:21:41 +01:00
template
test Recognize some OR clauses as compatible with functional dependencies 2020-03-18 16:41:49 +01:00
timezone Require stdint.h 2020-02-21 09:20:32 +01:00
tools Remove win32ver.rc from version_stamp.pl 2020-03-10 11:21:41 +01:00
tutorial
.gitignore
DEVELOPERS
Makefile
Makefile.global.in Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
Makefile.shlib Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nls-global.mk