Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1e9a6ba

Browse files
committed
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.
1 parent 23e2f9e commit 1e9a6ba

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/backend/optimizer/plan/createplan.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.199 2005/10/06 16:01:54 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/createplan.c,v 1.200 2005/10/13 00:06:46 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -1046,9 +1046,13 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
10461046
ListCell *l;
10471047

10481048
/*
1049-
* Here, we detect both obvious redundancies and qual-free subplans.
1050-
* A qual-free subplan would cause us to generate "... OR true ..."
1051-
* which we may as well reduce to just "true".
1049+
* Here, we only detect qual-free subplans. A qual-free subplan would
1050+
* cause us to generate "... OR true ..." which we may as well reduce
1051+
* to just "true". We do not try to eliminate redundant subclauses
1052+
* because (a) it's not as likely as in the AND case, and (b) we might
1053+
* well be working with hundreds or even thousands of OR conditions,
1054+
* perhaps from a long IN list. The performance of list_append_unique
1055+
* would be unacceptable.
10521056
*/
10531057
foreach(l, opath->bitmapquals)
10541058
{
@@ -1062,13 +1066,13 @@ create_bitmap_subplan(PlannerInfo *root, Path *bitmapqual,
10621066
if (subqual == NIL)
10631067
const_true_subqual = true;
10641068
else if (!const_true_subqual)
1065-
subquals = list_append_unique(subquals,
1066-
make_ands_explicit(subqual));
1069+
subquals = lappend(subquals,
1070+
make_ands_explicit(subqual));
10671071
if (subindexqual == NIL)
10681072
const_true_subindexqual = true;
10691073
else if (!const_true_subindexqual)
1070-
subindexquals = list_append_unique(subindexquals,
1071-
make_ands_explicit(subindexqual));
1074+
subindexquals = lappend(subindexquals,
1075+
make_ands_explicit(subindexqual));
10721076
}
10731077
plan = (Plan *) make_bitmap_or(subplans);
10741078
plan->startup_cost = opath->path.startup_cost;

src/backend/optimizer/util/restrictinfo.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.39 2005/07/28 20:26:21 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/util/restrictinfo.c,v 1.40 2005/10/13 00:06:46 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -123,9 +123,13 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
123123
List *withoutris = NIL;
124124

125125
/*
126-
* Here, we detect both obvious redundancies and qual-free subplans.
127-
* A qual-free subplan would cause us to generate "... OR true ..."
128-
* which we may as well reduce to just "true".
126+
* Here, we only detect qual-free subplans. A qual-free subplan would
127+
* cause us to generate "... OR true ..." which we may as well reduce
128+
* to just "true". We do not try to eliminate redundant subclauses
129+
* because (a) it's not as likely as in the AND case, and (b) we might
130+
* well be working with hundreds or even thousands of OR conditions,
131+
* perhaps from a long IN list. The performance of list_append_unique
132+
* would be unacceptable.
129133
*/
130134
foreach(l, opath->bitmapquals)
131135
{
@@ -144,12 +148,12 @@ make_restrictinfo_from_bitmapqual(Path *bitmapqual,
144148
return NIL;
145149
}
146150
/* Create AND subclause with RestrictInfos */
147-
withris = list_append_unique(withris,
148-
make_ands_explicit(sublist));
151+
withris = lappend(withris,
152+
make_ands_explicit(sublist));
149153
/* And one without */
150154
sublist = get_actual_clauses(sublist);
151-
withoutris = list_append_unique(withoutris,
152-
make_ands_explicit(sublist));
155+
withoutris = lappend(withoutris,
156+
make_ands_explicit(sublist));
153157
}
154158

155159
/*

0 commit comments

Comments
 (0)