mirror of
https://github.com/postgres/postgres.git
synced 2026-06-09 08:42:38 -04:00
Don't try to run clauseless index scans on index types that don't support
it. Per report from Marinos Yannikos.
This commit is contained in:
parent
25bd3019e0
commit
eecc92564d
1 changed files with 17 additions and 7 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.167.4.1 2005/03/01 00:25:45 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.167.4.2 2005/04/20 21:48:12 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
@ -145,11 +145,16 @@ create_index_paths(Query *root, RelOptInfo *rel)
|
||||||
* 2. Compute pathkeys describing index's ordering, if any, then
|
* 2. Compute pathkeys describing index's ordering, if any, then
|
||||||
* see how many of them are actually useful for this query.
|
* see how many of them are actually useful for this query.
|
||||||
*/
|
*/
|
||||||
index_pathkeys = build_index_pathkeys(root, rel, index,
|
index_is_ordered = OidIsValid(index->ordering[0]);
|
||||||
ForwardScanDirection);
|
if (index_is_ordered)
|
||||||
index_is_ordered = (index_pathkeys != NIL);
|
{
|
||||||
useful_pathkeys = truncate_useless_pathkeys(root, rel,
|
index_pathkeys = build_index_pathkeys(root, rel, index,
|
||||||
index_pathkeys);
|
ForwardScanDirection);
|
||||||
|
useful_pathkeys = truncate_useless_pathkeys(root, rel,
|
||||||
|
index_pathkeys);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
useful_pathkeys = NIL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 3. Generate an indexscan path if there are relevant restriction
|
* 3. Generate an indexscan path if there are relevant restriction
|
||||||
|
|
@ -159,10 +164,15 @@ create_index_paths(Query *root, RelOptInfo *rel)
|
||||||
* If there is a predicate, consider it anyway since the index
|
* If there is a predicate, consider it anyway since the index
|
||||||
* predicate has already been found to match the query. The
|
* predicate has already been found to match the query. The
|
||||||
* selectivity of the predicate might alone make the index useful.
|
* selectivity of the predicate might alone make the index useful.
|
||||||
|
*
|
||||||
|
* Note: not all index AMs support scans with no restriction clauses.
|
||||||
|
* We assume here that the AM does so if and only if it supports
|
||||||
|
* ordered scans. (It would probably be better if there were a
|
||||||
|
* specific flag for this in pg_am, but there's not.)
|
||||||
*/
|
*/
|
||||||
if (restrictclauses != NIL ||
|
if (restrictclauses != NIL ||
|
||||||
useful_pathkeys != NIL ||
|
useful_pathkeys != NIL ||
|
||||||
index->indpred != NIL)
|
(index->indpred != NIL && index_is_ordered))
|
||||||
add_path(rel, (Path *)
|
add_path(rel, (Path *)
|
||||||
create_index_path(root, rel, index,
|
create_index_path(root, rel, index,
|
||||||
restrictclauses,
|
restrictclauses,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue