Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit96d66bc

Browse files
committed
Improve performance of OverrideSearchPathMatchesCurrent().
This function was initially coded on the assumption that it would not beperformance-critical, but that turns out to be wrong in workloads thatare heavily dependent on the speed of plpgsql functions. Speed it up byhard-coding the comparison rules, thereby avoiding palloc/pfree trafficfrom creating and immediately freeing an OverrideSearchPath object.Per report from Scott Marlowe.
1 parente384ed6 commit96d66bc

File tree

1 file changed

+37
-13
lines changed

1 file changed

+37
-13
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,20 +3145,44 @@ CopyOverrideSearchPath(OverrideSearchPath *path)
31453145
bool
31463146
OverrideSearchPathMatchesCurrent(OverrideSearchPath*path)
31473147
{
3148-
/* Easiest way to do this is GetOverrideSearchPath() and compare */
3149-
boolresult;
3150-
OverrideSearchPath*cur;
3148+
ListCell*lc,
3149+
*lcp;
31513150

3152-
cur=GetOverrideSearchPath(CurrentMemoryContext);
3153-
if (path->addCatalog==cur->addCatalog&&
3154-
path->addTemp==cur->addTemp&&
3155-
equal(path->schemas,cur->schemas))
3156-
result= true;
3157-
else
3158-
result= false;
3159-
list_free(cur->schemas);
3160-
pfree(cur);
3161-
returnresult;
3151+
recomputeNamespacePath();
3152+
3153+
/* We scan down the activeSearchPath to see if it matches the input. */
3154+
lc=list_head(activeSearchPath);
3155+
3156+
/* If path->addTemp, first item should be my temp namespace. */
3157+
if (path->addTemp)
3158+
{
3159+
if (lc&&lfirst_oid(lc)==myTempNamespace)
3160+
lc=lnext(lc);
3161+
else
3162+
return false;
3163+
}
3164+
/* If path->addCatalog, next item should be pg_catalog. */
3165+
if (path->addCatalog)
3166+
{
3167+
if (lc&&lfirst_oid(lc)==PG_CATALOG_NAMESPACE)
3168+
lc=lnext(lc);
3169+
else
3170+
return false;
3171+
}
3172+
/* We should now be looking at the activeCreationNamespace. */
3173+
if (activeCreationNamespace!= (lc ?lfirst_oid(lc) :InvalidOid))
3174+
return false;
3175+
/* The remainder of activeSearchPath should match path->schemas. */
3176+
foreach(lcp,path->schemas)
3177+
{
3178+
if (lc&&lfirst_oid(lc)==lfirst_oid(lcp))
3179+
lc=lnext(lc);
3180+
else
3181+
return false;
3182+
}
3183+
if (lc)
3184+
return false;
3185+
return true;
31623186
}
31633187

31643188
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp