Skip to content

Commit d54ca56

Browse files
committed
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.
1 parent a238bd1 commit d54ca56

File tree

3 files changed

+311
-6
lines changed

3 files changed

+311
-6
lines changed

src/backend/catalog/namespace.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.102 2007/11/25 02:09:46 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.103 2007/11/28 18:47:56 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -3006,6 +3006,40 @@ fetch_search_path(bool includeImplicit)
30063006
return result;
30073007
}
30083008

3009+
/*
3010+
* Fetch the active search path into a caller-allocated array of OIDs.
3011+
* Returns the number of path entries. (If this is more than sarray_len,
3012+
* then the data didn't fit and is not all stored.)
3013+
*
3014+
* The returned list always includes the implicitly-prepended namespaces,
3015+
* but never includes the temp namespace. (This is suitable for existing
3016+
* users, which would want to ignore the temp namespace anyway.) This
3017+
* definition allows us to not worry about initializing the temp namespace.
3018+
*/
3019+
int
3020+
fetch_search_path_array(Oid *sarray, int sarray_len)
3021+
{
3022+
int count = 0;
3023+
ListCell *l;
3024+
3025+
recomputeNamespacePath();
3026+
3027+
foreach(l, activeSearchPath)
3028+
{
3029+
Oid namespaceId = lfirst_oid(l);
3030+
3031+
if (namespaceId == myTempNamespace)
3032+
continue; /* do not include temp namespace */
3033+
3034+
if (count < sarray_len)
3035+
sarray[count] = namespaceId;
3036+
count++;
3037+
}
3038+
3039+
return count;
3040+
}
3041+
3042+
30093043
/*
30103044
* Export the FooIsVisible functions as SQL-callable functions.
30113045
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy