pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Use functional dependencies to estimate ScalarArrayOpExpr
Date: Sat, 14 Mar 2020 15:15:43 +0000
Message-ID: <E1jD8Vr-0007rv-QB@gemulon.postgresql.org> (raw)

Use functional dependencies to estimate ScalarArrayOpExpr

Until now functional dependencies supported only simple equality clauses
and clauses that can be trivially translated to equalities. This commit
allows estimation of some ScalarArrayOpExpr (IN/ANY) clauses.

For IN clauses we can do this thanks to using operator with equality
semantics, which means an IN clause

    WHERE c IN (1, 2, ..., N)

can be translated to

    WHERE (c = 1 OR c = 2 OR ... OR c = N)

IN clauses are now considered compatible with functional dependencies,
and rely on the same assumption of consistency of queries with data
(which is an assumption we already used for simple equality clauses).
This applies also to ALL clauses with an equality operator, which can be
considered equivalent to IN clause.

ALL clauses are still considered incompatible, although there's some
discussion about maybe relaxing this in the future.

Author: Pierre Ducroquet
Reviewed-by: Tomas Vondra, Dean Rasheed
Discussion: https://www.postgresql.org/message-id/flat/13902317.Eha0YfKkKy%40pierred-pdoc

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8f321bd16cdb11307f17007eb3c55b65d7d323ef

Modified Files
--------------
doc/src/sgml/perform.sgml               |   3 +-
src/backend/statistics/dependencies.c   |  38 ++++++
src/test/regress/expected/stats_ext.out | 224 ++++++++++++++++++++++++++++++++
src/test/regress/sql/stats_ext.sql      |  80 ++++++++++++
4 files changed, 344 insertions(+), 1 deletion(-)



Message-ID: <E1jD8Vr-0007rv-QB@gemulon.postgresql.org>
Permalink:  ../E1jD8Vr-0007rv-QB@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jD8Vr-0007rv-QB@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org
  Subject: Re: pgsql: Use functional dependencies to estimate ScalarArrayOpExpr
  In-Reply-To: <E1jD8Vr-0007rv-QB@gemulon.postgresql.org>
  References: <E1jD8Vr-0007rv-QB@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox