Commit 1e9a6ba5 authored by Tom Lane's avatar Tom Lane

Don't try to remove duplicate OR-subclauses in create_bitmap_subplan and

make_restrictinfo_from_bitmapqual.  The likelihood of finding duplicates
seems much less than in the AND-subclause case, and the cost much higher,
because OR lists with hundreds or even thousands of subclauses are not
uncommon.  Per discussion with Ilia Kantor and andrew@supernews.
parent 23e2f9eb
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.199 2005/10/06 16:01:54 tgl Exp $ * $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.200 2005/10/13 00:06:46 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1046,9 +1046,13 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, ...@@ -1046,9 +1046,13 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
ListCell *l; ListCell *l;
/* /*
* Here, we detect both obvious redundancies and qual-free subplans. * Here, we only detect qual-free subplans. A qual-free subplan would
* A qual-free subplan would cause us to generate "... OR true ..." * cause us to generate "... OR true ..." which we may as well reduce
* which we may as well reduce to just "true". * to just "true". We do not try to eliminate redundant subclauses
* because (a) it's not as likely as in the AND case, and (b) we might
* well be working with hundreds or even thousands of OR conditions,
* perhaps from a long IN list. The performance of list_append_unique
* would be unacceptable.
*/ */
foreach(l, opath->bitmapquals) foreach(l, opath->bitmapquals)
{ {
...@@ -1062,12 +1066,12 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual, ...@@ -1062,12 +1066,12 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
if (subqual == NIL) if (subqual == NIL)
const_true_subqual = true; const_true_subqual = true;
else if (!const_true_subqual) else if (!const_true_subqual)
subquals = list_append_unique(subquals, subquals = lappend(subquals,
make_ands_explicit(subqual)); make_ands_explicit(subqual));
if (subindexqual == NIL) if (subindexqual == NIL)
const_true_subindexqual = true; const_true_subindexqual = true;
else if (!const_true_subindexqual) else if (!const_true_subindexqual)
subindexquals = list_append_unique(subindexquals, subindexquals = lappend(subindexquals,
make_ands_explicit(subindexqual)); make_ands_explicit(subindexqual));
} }
plan = (Plan *) make_bitmap_or(subplans); plan = (Plan *) make_bitmap_or(subplans);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.39 2005/07/28 20:26:21 tgl Exp $ * $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.40 2005/10/13 00:06:46 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -123,9 +123,13 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, ...@@ -123,9 +123,13 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
List *withoutris = NIL; List *withoutris = NIL;
/* /*
* Here, we detect both obvious redundancies and qual-free subplans. * Here, we only detect qual-free subplans. A qual-free subplan would
* A qual-free subplan would cause us to generate "... OR true ..." * cause us to generate "... OR true ..." which we may as well reduce
* which we may as well reduce to just "true". * to just "true". We do not try to eliminate redundant subclauses
* because (a) it's not as likely as in the AND case, and (b) we might
* well be working with hundreds or even thousands of OR conditions,
* perhaps from a long IN list. The performance of list_append_unique
* would be unacceptable.
*/ */
foreach(l, opath->bitmapquals) foreach(l, opath->bitmapquals)
{ {
...@@ -144,11 +148,11 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual, ...@@ -144,11 +148,11 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
return NIL; return NIL;
} }
/* Create AND subclause with RestrictInfos */ /* Create AND subclause with RestrictInfos */
withris = list_append_unique(withris, withris = lappend(withris,
make_ands_explicit(sublist)); make_ands_explicit(sublist));
/* And one without */ /* And one without */
sublist = get_actual_clauses(sublist); sublist = get_actual_clauses(sublist);
withoutris = list_append_unique(withoutris, withoutris = lappend(withoutris,
make_ands_explicit(sublist)); make_ands_explicit(sublist));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment