postgresql/src/backend
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
..
access nbtree: Remove useless local variables. 2020-03-17 18:39:26 -07:00
bootstrap Unify several ways to tracking backend type 2020-03-13 14:01:10 +01:00
catalog Refactor our checks for valid function and aggregate signatures. 2020-03-17 19:36:41 -04:00
commands Fix typo in indexcmds.c 2020-03-18 11:13:12 +09:00
executor Remove bogus assertion about polymorphic SQL function result. 2020-03-17 14:54:46 -04:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit Extend ExecBuildAggTrans() to support a NULL pointer check. 2020-03-04 17:29:18 -08:00
lib Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
libpq Introduce macros for typalign and typstorage constants. 2020-03-04 10:34:25 -05:00
main Add PostgreSQL home page to --help output 2020-02-28 13:12:21 +01:00
nodes Marginal comments and docs cleanup. 2020-03-10 17:34:09 -04:00
optimizer Save calculated transitionSpace in Agg node. 2020-02-27 11:20:56 -08:00
parser Refactor our checks for valid function and aggregate signatures. 2020-03-17 19:36:41 -04:00
partitioning Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
po Translation updates 2019-06-17 15:30:20 +02:00
port Update copyrights for 2020 2020-01-01 12:21:45 -05:00
postmaster Remove am_syslogger global variable 2020-03-13 14:01:15 +01:00
regex Update copyrights for 2020 2020-01-01 12:21:45 -05:00
replication Remove logical_read_local_xlog_page 2020-03-17 18:18:01 -03:00
rewrite Make rewriter prevent auto-updates on views with conditional INSTEAD rules. 2020-01-14 09:52:21 +00:00
snowball Update copyrights for 2020 2020-01-01 12:21:45 -05:00
statistics Recognize some OR clauses as compatible with functional dependencies 2020-03-18 16:41:49 +01:00
storage Add missing errcode() in a few ereport calls. 2020-03-18 09:27:14 +05:30
tcop Refactor ps_status.c API 2020-03-11 16:38:31 +01:00
tsearch Remove useless pfree()s at the ends of various ValuePerCall SRFs. 2020-03-16 21:36:53 -04:00
utils Remove useless pfree()s at the ends of various ValuePerCall SRFs. 2020-03-16 21:36:53 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
nls.mk Translation updates 2019-05-20 16:00:53 +02:00