pgsql: Improve statistics estimation to make some use of DISTINCT in su

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve statistics estimation to make some use of DISTINCT in su
Date: 2012-02-16 22:34:12
Message-ID: E1Ry9u0-0004C1-H4@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve statistics estimation to make some use of DISTINCT in sub-queries.

Formerly, we just punted when trying to estimate stats for variables coming
out of sub-queries using DISTINCT, on the grounds that whatever stats we
might have for underlying table columns would be inapplicable. But if the
sub-query has only one DISTINCT column, we can consider its output variable
as being unique, which is useful information all by itself. The scope of
this improvement is pretty narrow, but it costs nearly nothing, so we might
as well do it. Per discussion with Andres Freund.

This patch differs from the draft I submitted yesterday in updating various
comments about vardata.isunique (to reflect its extended meaning) and in
tweaking the interaction with security_barrier views. There does not seem
to be a reason why we can't use this sort of knowledge even when the
sub-query is such a view.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/4767bc8ff2edc1258cf4d8a83155d4cedd724231

Modified Files
--------------
src/backend/utils/adt/selfuncs.c | 94 ++++++++++++++++++++++++--------------
src/include/utils/selfuncs.h | 2 +-
2 files changed, 60 insertions(+), 36 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2012-02-17 01:01:05 pgsql: Fix longstanding error in contrib/intarray's int[] & int[] opera
Previous Message Robert Haas 2012-02-16 18:26:20 pgsql: pg_dump: Miscellaneous tightening based on recent refactorings.