Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf7430af

Browse files
committed
Fix OR index selectivity problem.
1 parentc831d08 commitf7430af

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

‎src/backend/optimizer/path/orindxpath.c

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.22 1999/03/0813:35:50 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.23 1999/03/0814:01:55 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -33,8 +33,7 @@
3333

3434
staticvoid
3535
best_or_subclause_indices(Query*root,RelOptInfo*rel,List*subclauses,
36-
List*indices,List*examined_indexids,Costsubcost,List*selectivities,
37-
List**indexids,Cost*cost,List**selecs);
36+
List*indices,List**indexids,Cost*cost,Cost*selec);
3837
staticvoidbest_or_subclause_index(Query*root,RelOptInfo*rel,Expr*subclause,
3938
List*indices,int*indexid,Cost*cost,Cost*selec);
4039

@@ -87,20 +86,17 @@ create_or_index_paths(Query *root,
8786
if (index_flag)
8887
{/* used to be a lisp every function */
8988
IndexPath*pathnode=makeNode(IndexPath);
90-
List*indexids;
89+
List*indexids=NIL;
9190
Costcost;
92-
List*selecs;
91+
Costselec;
9392

9493
best_or_subclause_indices(root,
9594
rel,
9695
clausenode->clause->args,
9796
clausenode->indexids,
98-
NIL,
99-
(Cost)0,
100-
NIL,
10197
&indexids,
10298
&cost,
103-
&selecs);
99+
&selec);
104100

105101
pathnode->path.pathtype=T_IndexScan;
106102
pathnode->path.parent=rel;
@@ -132,7 +128,7 @@ create_or_index_paths(Query *root,
132128
((Path*)pathnode)->path_cost+=xfunc_get_path_cost((Path)pathnode);
133129
}
134130
#endif
135-
clausenode->selectivity= (Cost)floatVal(lfirst(selecs));
131+
clausenode->selectivity= (Cost)selec;
136132
t_list=lappend(t_list,pathnode);
137133
}
138134
}
@@ -154,8 +150,7 @@ create_or_index_paths(Query *root,
154150
* 'examined_indexids' is a list of those index ids to be used with
155151
*subclauses that have already been examined
156152
* 'subcost' is the cost of using the indices in 'examined_indexids'
157-
* 'selectivities' is a list of the selectivities of subclauses that
158-
*have already been examined
153+
* 'selec' is a list of all subclauses that have already been examined
159154
*
160155
* Returns a list of the indexids, cost, and selectivities of each
161156
* subclause, e.g., ((i1 i2 i3) cost (s1 s2 s3)), where 'i' is an OID,
@@ -166,15 +161,15 @@ best_or_subclause_indices(Query *root,
166161
RelOptInfo*rel,
167162
List*subclauses,
168163
List*indices,
169-
List*examined_indexids,
170-
Costsubcost,
171-
List*selectivities,
172164
List**indexids,/* return value */
173-
Cost*cost,/* return value */
174-
List**selecs)/* return value */
165+
Cost*cost,/* return value */
166+
Cost*selec)/* return value */
175167
{
176-
List*slist;
168+
List*slist;
177169

170+
*selec= (Cost)0.0;
171+
*cost= (Cost)0.0;
172+
178173
foreach(slist,subclauses)
179174
{
180175
intbest_indexid;
@@ -184,17 +179,15 @@ best_or_subclause_indices(Query *root,
184179
best_or_subclause_index(root,rel,lfirst(slist),lfirst(indices),
185180
&best_indexid,&best_cost,&best_selec);
186181

187-
examined_indexids=lappendi(examined_indexids,best_indexid);
188-
subcost+=best_cost;
189-
selectivities=lappend(selectivities,makeFloat(best_selec));
182+
*indexids=lappendi(*indexids,best_indexid);
183+
*cost+=best_cost;
184+
*selec+=best_selec;
185+
if (*selec> (Cost)1.0)
186+
*selec= (Cost)1.0;
190187

191188
indices=lnext(indices);
192189
}
193190

194-
*indexids=examined_indexids;
195-
*cost=subcost;
196-
*selecs=selectivities;
197-
198191
return;
199192
}
200193

‎src/backend/optimizer/util/plancat.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.26 1999/02/21 03:48:54 scrappy Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.27 1999/03/08 14:01:57 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -545,7 +545,6 @@ IndexSelectivity(Oid indexrelid,
545545
select=1.0;
546546
for (n=0;n<nIndexKeys;++n)
547547
{
548-
549548
/*
550549
* Find the AM class for this key.
551550
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp