Limit the number of rel sets considered in consider_index_join_outer_rels.
In bug #7626, Brian Dunavant exposes a performance problem created by
commit 3b8968f25232ad09001bf35ab4cc59f5a501193e: that commit attempted to
consider *all* possible combinations of indexable join clauses, but if said
clauses join to enough different relations, there's an exponential increase
in the number of outer-relation sets considered.
In Brian's example, all the clauses come from the same equivalence class,
which means it's redundant to use more than one of them in an indexscan
anyway. So we can prevent the problem in this class of cases (which is
probably the majority of real examples) by rejecting combinations that
would only serve to add a known-redundant clause.
But that still leaves us exposed to exponential growth of planning time
when the query has a lot of non-equivalence join clauses that are usable
with the same index. I chose to prevent such cases by setting an upper
limit on the number of relation sets considered, equal to ten times the
number of index clauses considered so far. (This sliding limit still
allows new relsets to be added on as we move to additional index columns,
which is probably more important than considering even more combinations of
clauses for the previous column.) This should keep the amount of work done
roughly linear rather than exponential in the apparent query complexity.
This part of the fix is pretty ad-hoc; but without a clearer idea of
real-world cases for which this would result in markedly inferior plans,
it's hard to see how to do better.
src/backend/optimizer/path/indxpath.c | 64 +++++++++++++++++++++++++++++++--
1 files changed, 61 insertions(+), 3 deletions(-)
pgsql-committers by date
|Next:||From: Tom Lane||Date: 2012-11-01 23:49:20|
|Subject: pgsql: Fix bogus handling of $(X) (i.e.,".exe") in isolationtester Mak|
|Previous:||From: Peter Eisentraut||Date: 2012-11-01 04:05:33|
|Subject: Re: [COMMITTERS] pgsql: Preserve intermediate .c files in coverage