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

Commiteb4f58a

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 parenta8ac7d8 commiteb4f58a

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-
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.173 2005/04/11 23:06:55 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.174 2005/04/20 21:48:04 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -146,11 +146,16 @@ create_index_paths(Query *root, RelOptInfo *rel)
146146
* 2. Compute pathkeys describing index's ordering, if any, then
147147
* see how many of them are actually useful for this query.
148148
*/
149-
index_pathkeys=build_index_pathkeys(root,index,
150-
ForwardScanDirection);
151-
index_is_ordered= (index_pathkeys!=NIL);
152-
useful_pathkeys=truncate_useless_pathkeys(root,rel,
153-
index_pathkeys);
149+
index_is_ordered=OidIsValid(index->ordering[0]);
150+
if (index_is_ordered)
151+
{
152+
index_pathkeys=build_index_pathkeys(root,index,
153+
ForwardScanDirection);
154+
useful_pathkeys=truncate_useless_pathkeys(root,rel,
155+
index_pathkeys);
156+
}
157+
else
158+
useful_pathkeys=NIL;
154159

155160
/*
156161
* 3. Generate an indexscan path if there are relevant restriction
@@ -160,10 +165,15 @@ create_index_paths(Query *root, RelOptInfo *rel)
160165
* If there is a predicate, consider it anyway since the index
161166
* predicate has already been found to match the query. The
162167
* selectivity of the predicate might alone make the index useful.
168+
*
169+
* Note: not all index AMs support scans with no restriction clauses.
170+
* We assume here that the AM does so if and only if it supports
171+
* ordered scans. (It would probably be better if there were a
172+
* specific flag for this in pg_am, but there's not.)
163173
*/
164174
if (restrictclauses!=NIL||
165175
useful_pathkeys!=NIL||
166-
index->indpred!=NIL)
176+
(index->indpred!=NIL&&index_is_ordered))
167177
add_path(rel, (Path*)
168178
create_index_path(root,index,
169179
restrictclauses,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp