diff options
Diffstat (limited to 'src/backend/utils/cache/syscache.c')
-rw-r--r-- | src/backend/utils/cache/syscache.c | 169 |
1 files changed, 122 insertions, 47 deletions
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index ffcb26e3c55..d23fbb9ce2b 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.103 2006/05/03 22:45:26 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/utils/cache/syscache.c,v 1.104 2006/06/15 02:08:09 tgl Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -55,14 +55,18 @@ the list sorted alphabetically and adjust the cache numbers accordingly. - Add your entry to the cacheinfo[] array below. All cache lists are - alphabetical, so add it in the proper place. Specify the relation - OID, index OID, number of keys, and key attribute numbers. If the - relation contains tuples that are associated with a particular relation - (for example, its attributes, rules, triggers, etc) then specify the - attribute number that contains the OID of the associated relation. - This is used by CatalogCacheFlushRelation() to remove the correct - tuples during a table drop or relcache invalidation event. + Add your entry to the cacheinfo[] array below. All cache lists are + alphabetical, so add it in the proper place. Specify the relation OID, + index OID, number of keys, key attribute numbers, and number of hash + buckets. If the relation contains tuples that are associated with a + particular relation (for example, its attributes, rules, triggers, etc) + then specify the attribute number that contains the OID of the associated + relation. This is used by CatalogCacheFlushRelation() to remove the + correct tuples during a table drop or relcache invalidation event. + + The number of hash buckets must be a power of 2. It's reasonable to + set this to the number of entries that might be in the particular cache + in a medium-size database. There must be a unique index underlying each syscache (ie, an index whose key is the same as that of the cache). If there is not one @@ -90,6 +94,7 @@ struct cachedesc int reloidattr; /* attr number of rel OID reference, or 0 */ int nkeys; /* # of keys needed for cache lookup */ int key[4]; /* attribute numbers of key attrs */ + int nbuckets; /* number of hash buckets for this cache */ }; static const struct cachedesc cacheinfo[] = { @@ -102,7 +107,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 32 + }, {AccessMethodRelationId, /* AMNAME */ AmNameIndexId, 0, @@ -112,7 +119,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 4 + }, {AccessMethodRelationId, /* AMOID */ AmOidIndexId, 0, @@ -122,7 +131,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 4 + }, {AccessMethodOperatorRelationId, /* AMOPOPID */ AccessMethodOperatorIndexId, 0, @@ -132,7 +143,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_amop_amopclaid, 0, 0 - }}, + }, + 64 + }, {AccessMethodOperatorRelationId, /* AMOPSTRATEGY */ AccessMethodStrategyIndexId, 0, @@ -142,7 +155,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_amop_amopsubtype, Anum_pg_amop_amopstrategy, 0 - }}, + }, + 64 + }, {AccessMethodProcedureRelationId, /* AMPROCNUM */ AccessMethodProcedureIndexId, 0, @@ -152,7 +167,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_amproc_amprocsubtype, Anum_pg_amproc_amprocnum, 0 - }}, + }, + 64 + }, {AttributeRelationId, /* ATTNAME */ AttributeRelidNameIndexId, Anum_pg_attribute_attrelid, @@ -162,7 +179,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_attribute_attname, 0, 0 - }}, + }, + 2048 + }, {AttributeRelationId, /* ATTNUM */ AttributeRelidNumIndexId, Anum_pg_attribute_attrelid, @@ -172,7 +191,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_attribute_attnum, 0, 0 - }}, + }, + 2048 + }, {AuthMemRelationId, /* AUTHMEMMEMROLE */ AuthMemMemRoleIndexId, 0, @@ -182,7 +203,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_auth_members_roleid, 0, 0 - }}, + }, + 128 + }, {AuthMemRelationId, /* AUTHMEMROLEMEM */ AuthMemRoleMemIndexId, 0, @@ -192,7 +215,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_auth_members_member, 0, 0 - }}, + }, + 128 + }, {AuthIdRelationId, /* AUTHNAME */ AuthIdRolnameIndexId, 0, @@ -202,7 +227,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 128 + }, {AuthIdRelationId, /* AUTHOID */ AuthIdOidIndexId, 0, @@ -212,7 +239,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 128 + }, { CastRelationId, /* CASTSOURCETARGET */ CastSourceTargetIndexId, @@ -223,7 +252,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_cast_casttarget, 0, 0 - }}, + }, + 256 + }, {OperatorClassRelationId, /* CLAAMNAMENSP */ OpclassAmNameNspIndexId, 0, @@ -233,7 +264,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_opclass_opcname, Anum_pg_opclass_opcnamespace, 0 - }}, + }, + 64 + }, {OperatorClassRelationId, /* CLAOID */ OpclassOidIndexId, 0, @@ -243,7 +276,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 64 + }, {ConversionRelationId, /* CONDEFAULT */ ConversionDefaultIndexId, 0, @@ -253,7 +288,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_conversion_conforencoding, Anum_pg_conversion_contoencoding, ObjectIdAttributeNumber, - }}, + }, + 128 + }, {ConversionRelationId, /* CONNAMENSP */ ConversionNameNspIndexId, 0, @@ -263,7 +300,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_conversion_connamespace, 0, 0 - }}, + }, + 128 + }, {ConversionRelationId, /* CONOID */ ConversionOidIndexId, 0, @@ -273,7 +312,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 128 + }, {DatabaseRelationId, /* DATABASEOID */ DatabaseOidIndexId, 0, @@ -283,7 +324,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 4 + }, {IndexRelationId, /* INDEXRELID */ IndexRelidIndexId, Anum_pg_index_indrelid, @@ -293,7 +336,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 1024 + }, {InheritsRelationId, /* INHRELID */ InheritsRelidSeqnoIndexId, Anum_pg_inherits_inhrelid, @@ -303,7 +348,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_inherits_inhseqno, 0, 0 - }}, + }, + 256 + }, {LanguageRelationId, /* LANGNAME */ LanguageNameIndexId, 0, @@ -313,7 +360,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 4 + }, {LanguageRelationId, /* LANGOID */ LanguageOidIndexId, 0, @@ -323,7 +372,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 4 + }, {NamespaceRelationId, /* NAMESPACENAME */ NamespaceNameIndexId, 0, @@ -333,7 +384,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 256 + }, {NamespaceRelationId, /* NAMESPACEOID */ NamespaceOidIndexId, 0, @@ -343,7 +396,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 256 + }, {OperatorRelationId, /* OPERNAMENSP */ OperatorNameNspIndexId, 0, @@ -353,7 +408,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_operator_oprleft, Anum_pg_operator_oprright, Anum_pg_operator_oprnamespace - }}, + }, + 1024 + }, {OperatorRelationId, /* OPEROID */ OperatorOidIndexId, 0, @@ -363,7 +420,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 1024 + }, {ProcedureRelationId, /* PROCNAMEARGSNSP */ ProcedureNameArgsNspIndexId, 0, @@ -373,7 +432,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_proc_proargtypes, Anum_pg_proc_pronamespace, 0 - }}, + }, + 2048 + }, {ProcedureRelationId, /* PROCOID */ ProcedureOidIndexId, 0, @@ -383,7 +444,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 2048 + }, {RelationRelationId, /* RELNAMENSP */ ClassNameNspIndexId, ObjectIdAttributeNumber, @@ -393,7 +456,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_class_relnamespace, 0, 0 - }}, + }, + 1024 + }, {RelationRelationId, /* RELOID */ ClassOidIndexId, ObjectIdAttributeNumber, @@ -403,7 +468,9 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }}, + }, + 1024 + }, {RewriteRelationId, /* RULERELNAME */ RewriteRelRulenameIndexId, Anum_pg_rewrite_ev_class, @@ -413,7 +480,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_rewrite_rulename, 0, 0 - }}, + }, + 1024 + }, {StatisticRelationId, /* STATRELATT */ StatisticRelidAttnumIndexId, Anum_pg_statistic_starelid, @@ -423,7 +492,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_statistic_staattnum, 0, 0 - }}, + }, + 1024 + }, {TypeRelationId, /* TYPENAMENSP */ TypeNameNspIndexId, Anum_pg_type_typrelid, @@ -433,7 +504,9 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_type_typnamespace, 0, 0 - }}, + }, + 1024 + }, {TypeRelationId, /* TYPEOID */ TypeOidIndexId, Anum_pg_type_typrelid, @@ -443,11 +516,12 @@ static const struct cachedesc cacheinfo[] = { 0, 0, 0 - }} + }, + 1024 + } }; -static CatCache *SysCache[ - lengthof(cacheinfo)]; +static CatCache *SysCache[lengthof(cacheinfo)]; static int SysCacheSize = lengthof(cacheinfo); static bool CacheInitialized = false; @@ -476,7 +550,8 @@ InitCatalogCache(void) cacheinfo[cacheId].indoid, cacheinfo[cacheId].reloidattr, cacheinfo[cacheId].nkeys, - cacheinfo[cacheId].key); + cacheinfo[cacheId].key, + cacheinfo[cacheId].nbuckets); if (!PointerIsValid(SysCache[cacheId])) elog(ERROR, "could not initialize cache %u (%d)", cacheinfo[cacheId].reloid, cacheId); |