diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-20 21:48:04 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2005-04-20 21:48:04 +0000 |
commit | eb4f58ad4096b8d25535e8cb12bcaec066774025 (patch) | |
tree | 74539d37f91e5c684ff3b89d8d183f2b1a1dafe9 /src | |
parent | a8ac7d8713b2b60883ff86c8cc44b706fc361bae (diff) | |
download | postgresql-eb4f58ad4096b8d25535e8cb12bcaec066774025.tar.gz postgresql-eb4f58ad4096b8d25535e8cb12bcaec066774025.zip |
Don't try to run clauseless index scans on index types that don't support
it. Per report from Marinos Yannikos.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/optimizer/path/indxpath.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 21cf27745a4..937e2aed80e 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.173 2005/04/11 23:06:55 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.174 2005/04/20 21:48:04 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -146,11 +146,16 @@ create_index_paths(Query *root, RelOptInfo *rel) * 2. Compute pathkeys describing index's ordering, if any, then * see how many of them are actually useful for this query. */ - index_pathkeys = build_index_pathkeys(root, index, - ForwardScanDirection); - index_is_ordered = (index_pathkeys != NIL); - useful_pathkeys = truncate_useless_pathkeys(root, rel, - index_pathkeys); + index_is_ordered = OidIsValid(index->ordering[0]); + if (index_is_ordered) + { + index_pathkeys = build_index_pathkeys(root, index, + ForwardScanDirection); + useful_pathkeys = truncate_useless_pathkeys(root, rel, + index_pathkeys); + } + else + useful_pathkeys = NIL; /* * 3. Generate an indexscan path if there are relevant restriction @@ -160,10 +165,15 @@ create_index_paths(Query *root, RelOptInfo *rel) * If there is a predicate, consider it anyway since the index * predicate has already been found to match the query. The * 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 || useful_pathkeys != NIL || - index->indpred != NIL) + (index->indpred != NIL && index_is_ordered)) add_path(rel, (Path *) create_index_path(root, index, restrictclauses, |