Cache whether an object is in pg_dist_object. Avoids redundant lookups for non-distributed objects

pull/3097/head
Philip Dubé 2019-10-09 18:17:36 +00:00 committed by Philip Dubé
parent 2a47cff7b7
commit dd490b6376
4 changed files with 6 additions and 4 deletions

View File

@ -54,7 +54,7 @@ CallDistributedProcedureRemotely(CallStmt *callStmt, DestReceiver *dest)
Oid functionId = funcExpr->funcid; Oid functionId = funcExpr->funcid;
procedure = LookupDistObjectCacheEntry(ProcedureRelationId, functionId, 0); procedure = LookupDistObjectCacheEntry(ProcedureRelationId, functionId, 0);
if (procedure == NULL) if (procedure == NULL || !procedure->isDistributed)
{ {
return false; return false;
} }

View File

@ -221,7 +221,7 @@ TryToDelegateFunctionCall(Query *query, bool *hasExternParam)
funcExpr = (FuncExpr *) targetEntry->expr; funcExpr = (FuncExpr *) targetEntry->expr;
procedure = LookupDistObjectCacheEntry(ProcedureRelationId, funcExpr->funcid, 0); procedure = LookupDistObjectCacheEntry(ProcedureRelationId, funcExpr->funcid, 0);
if (procedure == NULL) if (procedure == NULL || !procedure->isDistributed)
{ {
/* not a distributed function call */ /* not a distributed function call */
ereport(DEBUG4, (errmsg("function is not distributed"))); ereport(DEBUG4, (errmsg("function is not distributed")));

View File

@ -991,6 +991,7 @@ LookupDistObjectCacheEntry(Oid classid, Oid objid, int32 objsubid)
isNullArray); isNullArray);
cacheEntry->isValid = true; cacheEntry->isValid = true;
cacheEntry->isDistributed = true;
cacheEntry->distributionArgIndex = cacheEntry->distributionArgIndex =
DatumGetInt32(datumArray[Anum_pg_dist_object_distribution_argument_index - DatumGetInt32(datumArray[Anum_pg_dist_object_distribution_argument_index -
@ -1000,8 +1001,8 @@ LookupDistObjectCacheEntry(Oid classid, Oid objid, int32 objsubid)
} }
else else
{ {
/* return NULL, cacheEntry left invalid in hash table */ cacheEntry->isValid = true;
cacheEntry = NULL; cacheEntry->isDistributed = false;
} }
systable_endscan(pgDistObjectScan); systable_endscan(pgDistObjectScan);

View File

@ -110,6 +110,7 @@ typedef struct DistObjectCacheEntry
DistObjectCacheEntryKey key; DistObjectCacheEntryKey key;
bool isValid; bool isValid;
bool isDistributed;
int distributionArgIndex; int distributionArgIndex;
int colocationId; int colocationId;