mirror of https://github.com/citusdata/citus.git
Avoid cache lookups for internal PostgreSQL tables when checking for Citus tables
PostgreSQL starts assigning user OIDs from FirstNormalObjectId onward, so any relation with an OID below that is a system object and cannot be a Citus table. This change introduces an early bailout for such relationIds, eliminating unnecessary calls to BuildCitusTableCache. This optimization is particularly beneficial in performance-critical workflows—such as rapid connect -> query-catalog_table -> disconnect cycles—by avoiding the expensive cache build and lookup. Since BuildCitusTableCache operates under a lock, which can lead to contention among concurrent processes (and, in some cases, distributed deadlocks), bypassing it for internal tables improves both performance and stability.pull/7910/head
parent
ca8cb7ac5a
commit
0c24ebf6bb
|
@ -660,6 +660,18 @@ GetTableTypeName(Oid tableId)
|
|||
bool
|
||||
IsCitusTable(Oid relationId)
|
||||
{
|
||||
/*
|
||||
* PostgreSQL's OID generator assigns user operation OIDs starting
|
||||
* from FirstNormalObjectId. This means no user object can have
|
||||
* an OID lower than FirstNormalObjectId. Therefore, if the
|
||||
* relationId is less than FirstNormalObjectId
|
||||
* (i.e. in PostgreSQL's reserved range), we can immediately
|
||||
* return false, since such objects cannot be Citus tables.
|
||||
*/
|
||||
if (relationId < FirstNormalObjectId)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return LookupCitusTableCacheEntry(relationId) != NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue