7
7
*
8
8
*
9
9
* 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 $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
33
33
34
34
static void
35
35
best_or_subclause_indices (Query * root ,RelOptInfo * rel ,List * subclauses ,
36
- List * indices ,List * examined_indexids ,Cost subcost ,List * selectivities ,
37
- List * * indexids ,Cost * cost ,List * * selecs );
36
+ List * indices ,List * * indexids ,Cost * cost ,Cost * selec );
38
37
static void best_or_subclause_index (Query * root ,RelOptInfo * rel ,Expr * subclause ,
39
38
List * indices ,int * indexid ,Cost * cost ,Cost * selec );
40
39
@@ -87,20 +86,17 @@ create_or_index_paths(Query *root,
87
86
if (index_flag )
88
87
{/* used to be a lisp every function */
89
88
IndexPath * pathnode = makeNode (IndexPath );
90
- List * indexids ;
89
+ List * indexids = NIL ;
91
90
Cost cost ;
92
- List * selecs ;
91
+ Cost selec ;
93
92
94
93
best_or_subclause_indices (root ,
95
94
rel ,
96
95
clausenode -> clause -> args ,
97
96
clausenode -> indexids ,
98
- NIL ,
99
- (Cost )0 ,
100
- NIL ,
101
97
& indexids ,
102
98
& cost ,
103
- & selecs );
99
+ & selec );
104
100
105
101
pathnode -> path .pathtype = T_IndexScan ;
106
102
pathnode -> path .parent = rel ;
@@ -132,7 +128,7 @@ create_or_index_paths(Query *root,
132
128
((Path * )pathnode )-> path_cost += xfunc_get_path_cost ((Path )pathnode );
133
129
}
134
130
#endif
135
- clausenode -> selectivity = (Cost )floatVal ( lfirst ( selecs )) ;
131
+ clausenode -> selectivity = (Cost )selec ;
136
132
t_list = lappend (t_list ,pathnode );
137
133
}
138
134
}
@@ -154,8 +150,7 @@ create_or_index_paths(Query *root,
154
150
* 'examined_indexids' is a list of those index ids to be used with
155
151
*subclauses that have already been examined
156
152
* '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
159
154
*
160
155
* Returns a list of the indexids, cost, and selectivities of each
161
156
* 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,
166
161
RelOptInfo * rel ,
167
162
List * subclauses ,
168
163
List * indices ,
169
- List * examined_indexids ,
170
- Cost subcost ,
171
- List * selectivities ,
172
164
List * * indexids ,/* return value */
173
- Cost * cost ,/* return value */
174
- List * * selecs ) /* return value */
165
+ Cost * cost ,/* return value */
166
+ Cost * selec ) /* return value */
175
167
{
176
- List * slist ;
168
+ List * slist ;
177
169
170
+ * selec = (Cost )0.0 ;
171
+ * cost = (Cost )0.0 ;
172
+
178
173
foreach (slist ,subclauses )
179
174
{
180
175
int best_indexid ;
@@ -184,17 +179,15 @@ best_or_subclause_indices(Query *root,
184
179
best_or_subclause_index (root ,rel ,lfirst (slist ),lfirst (indices ),
185
180
& best_indexid ,& best_cost ,& best_selec );
186
181
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 ;
190
187
191
188
indices = lnext (indices );
192
189
}
193
190
194
- * indexids = examined_indexids ;
195
- * cost = subcost ;
196
- * selecs = selectivities ;
197
-
198
191
return ;
199
192
}
200
193