Commit d54ca567 authored by Tom Lane's avatar Tom Lane

Install a lookaside cache to speed up repeated lookups of the same operator

by short-circuiting schema search path and ambiguous-operator resolution
computations.  Remarkably, this buys as much as 45% speedup of repetitive
simple queries that involve operators that are not an exact match to the
input datatypes.  It should be marginally faster even for exact-match
cases, though I've not had success in proving an improvement in benchmark
tests.  Per report from Guillame Smet and subsequent discussion.
parent a238bd14
......@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.102 2007/11/25 02:09:46 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.103 2007/11/28 18:47:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -3006,6 +3006,40 @@ fetch_search_path(bool includeImplicit)
return result;
}
/*
* Fetch the active search path into a caller-allocated array of OIDs.
* Returns the number of path entries. (If this is more than sarray_len,
* then the data didn't fit and is not all stored.)
*
* The returned list always includes the implicitly-prepended namespaces,
* but never includes the temp namespace. (This is suitable for existing
* users, which would want to ignore the temp namespace anyway.) This
* definition allows us to not worry about initializing the temp namespace.
*/
int
fetch_search_path_array(Oid *sarray, int sarray_len)
{
int count = 0;
ListCell *l;
recomputeNamespacePath();
foreach(l, activeSearchPath)
{
Oid namespaceId = lfirst_oid(l);
if (namespaceId == myTempNamespace)
continue; /* do not include temp namespace */
if (count < sarray_len)
sarray[count] = namespaceId;
count++;
}
return count;
}
/*
* Export the FooIsVisible functions as SQL-callable functions.
*/
......
This diff is collapsed.
......@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.51 2007/11/15 22:25:17 momjian Exp $
* $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.52 2007/11/28 18:47:56 tgl Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -115,5 +115,6 @@ extern void AtEOSubXact_Namespace(bool isCommit, SubTransactionId mySubid,
extern char *namespace_search_path;
extern List *fetch_search_path(bool includeImplicit);
extern int fetch_search_path_array(Oid *sarray, int sarray_len);
#endif /* NAMESPACE_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment