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

Commit6fbda16

Browse files
committed
Don't try to run clauseless index scans on index types that don't support
it. Per report from Marinos Yannikos.
1 parentbdb2d69 commit6fbda16

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.112.2.1 2002/08/22 16:20:38 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.112.2.2 2005/04/20 21:48:39 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -187,11 +187,16 @@ create_index_paths(Query *root, RelOptInfo *rel)
187187
* 3. Compute pathkeys describing index's ordering, if any, then
188188
* see how many of them are actually useful for this query.
189189
*/
190-
index_pathkeys=build_index_pathkeys(root,rel,index,
191-
ForwardScanDirection);
192-
index_is_ordered= (index_pathkeys!=NIL);
193-
useful_pathkeys=truncate_useless_pathkeys(root,rel,
194-
index_pathkeys);
190+
index_is_ordered=OidIsValid(index->ordering[0]);
191+
if (index_is_ordered)
192+
{
193+
index_pathkeys=build_index_pathkeys(root,rel,index,
194+
ForwardScanDirection);
195+
useful_pathkeys=truncate_useless_pathkeys(root,rel,
196+
index_pathkeys);
197+
}
198+
else
199+
useful_pathkeys=NIL;
195200

196201
/*
197202
* 4. Generate an indexscan path if there are relevant restriction
@@ -201,10 +206,15 @@ create_index_paths(Query *root, RelOptInfo *rel)
201206
* If there is a predicate, consider it anyway since the index
202207
* predicate has already been found to match the query. The
203208
* selectivity of the predicate might alone make the index useful.
209+
*
210+
* Note: not all index AMs support scans with no restriction clauses.
211+
* We assume here that the AM does so if and only if it supports
212+
* ordered scans. (It would probably be better if there were a
213+
* specific flag for this in pg_am, but there's not.)
204214
*/
205215
if (restrictclauses!=NIL||
206216
useful_pathkeys!=NIL||
207-
index->indpred!=NIL)
217+
(index->indpred!=NIL&&index_is_ordered))
208218
add_path(rel, (Path*)
209219
create_index_path(root,rel,index,
210220
restrictclauses,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp