diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-28 22:32:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-28 22:32:50 +0000 |
commit | 8a6ac83dab3b3a5701a0508daa1d9356e2d59cdb (patch) | |
tree | 0f96d0304864f7439c90dc6ae6a1e30945051d1a /src/backend/optimizer/path/orindxpath.c | |
parent | 0f3c68aa436dca175d29a43e104146259b4b0a00 (diff) | |
download | postgresql-8a6ac83dab3b3a5701a0508daa1d9356e2d59cdb.tar.gz postgresql-8a6ac83dab3b3a5701a0508daa1d9356e2d59cdb.zip |
Fix some planner performance problems with large WHERE clauses, by
introducing new 'FastList' list-construction subroutines to use in
hot spots. This avoids the O(N^2) behavior of repeated lappend's
by keeping a tail pointer, while not changing behavior by reversing
list order as the lcons() method would do.
Diffstat (limited to 'src/backend/optimizer/path/orindxpath.c')
-rw-r--r-- | src/backend/optimizer/path/orindxpath.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index 101866867b9..10eb050f3a3 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.49 2002/12/12 15:49:31 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.50 2003/05/28 22:32:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -149,10 +149,12 @@ best_or_subclause_indices(Query *root, List *indices, IndexPath *pathnode) { + FastList infos; + FastList quals; List *slist; - pathnode->indexinfo = NIL; - pathnode->indexqual = NIL; + FastListInit(&infos); + FastListInit(&quals); pathnode->path.startup_cost = 0; pathnode->path.total_cost = 0; @@ -170,14 +172,17 @@ best_or_subclause_indices(Query *root, Assert(best_indexinfo != NULL); - pathnode->indexinfo = lappend(pathnode->indexinfo, best_indexinfo); - pathnode->indexqual = lappend(pathnode->indexqual, best_indexqual); + FastAppend(&infos, best_indexinfo); + FastAppend(&quals, best_indexqual); if (slist == subclauses) /* first scan? */ pathnode->path.startup_cost = best_startup_cost; pathnode->path.total_cost += best_total_cost; indices = lnext(indices); } + + pathnode->indexinfo = FastListValue(&infos); + pathnode->indexqual = FastListValue(&quals); } /* |