diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-02-19 20:11:20 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-02-19 20:11:20 +0000 |
commit | 786340441706ac1957a031f11ad1c2e5b6e18314 (patch) | |
tree | 4e6b689b96778e42e6cc679169f71dc180049e04 /src/backend/utils/cache/syscache.c | |
parent | 8e2998d8a6aebc2a3b22e6048fab8abe1c95f1f0 (diff) | |
download | postgresql-786340441706ac1957a031f11ad1c2e5b6e18314.tar.gz postgresql-786340441706ac1957a031f11ad1c2e5b6e18314.zip |
A bunch of changes aimed at reducing backend startup time...
Improve 'pg_internal.init' relcache entry preload mechanism so that it is
safe to use for all system catalogs, and arrange to preload a realistic
set of system-catalog entries instead of only the three nailed-in-cache
indexes that were formerly loaded this way. Fix mechanism for deleting
out-of-date pg_internal.init files: this must be synchronized with transaction
commit, not just done at random times within transactions. Drive it off
relcache invalidation mechanism so that no special-case tests are needed.
Cache additional information in relcache entries for indexes (their pg_index
tuples and index-operator OIDs) to eliminate repeated lookups. Also cache
index opclass info at the per-opclass level to avoid repeated lookups during
relcache load.
Generalize 'systable scan' utilities originally developed by Hiroshi,
move them into genam.c, use in a number of places where there was formerly
ugly code for choosing either heap or index scan. In particular this allows
simplification of the logic that prevents infinite recursion between syscache
and relcache during startup: we can easily switch to heapscans in relcache.c
when and where needed to avoid recursion, so IndexScanOK becomes simpler and
does not need any expensive initialization.
Eliminate useless opening of a heapscan data structure while doing an indexscan
(this saves an mdnblocks call and thus at least one kernel call).
Diffstat (limited to 'src/backend/utils/cache/syscache.c')
-rw-r--r-- | src/backend/utils/cache/syscache.c | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index e629bf48e46..dfbcccffbed 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.66 2001/10/25 05:49:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.67 2002/02/19 20:11:18 tgl Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -113,6 +113,16 @@ static struct cachedesc cacheinfo[] = { 0, 0 }}, + {AccessMethodRelationName, /* AMOID */ + AmOidIndex, + 0, + 1, + { + ObjectIdAttributeNumber, + 0, + 0, + 0 + }}, {AccessMethodOperatorRelationName, /* AMOPOPID */ AccessMethodOperatorIndex, 0, @@ -365,8 +375,7 @@ static struct cachedesc cacheinfo[] = { }} }; -static CatCache *SysCache[ - lengthof(cacheinfo)]; +static CatCache *SysCache[lengthof(cacheinfo)]; static int SysCacheSize = lengthof(cacheinfo); static bool CacheInitialized = false; @@ -383,7 +392,7 @@ IsCacheInitialized(void) * * Note that no database access is done here; we only allocate memory * and initialize the cache structure. Interrogation of the database - * to complete initialization of a cache happens only upon first use + * to complete initialization of a cache happens upon first use * of that cache. */ void @@ -412,6 +421,32 @@ InitCatalogCache(void) /* + * InitCatalogCachePhase2 - finish initializing the caches + * + * Finish initializing all the caches, including necessary database + * access. + * + * This is *not* essential; normally we allow syscaches to be initialized + * on first use. However, it is useful as a mechanism to preload the + * relcache with entries for the most-commonly-used system catalogs. + * Therefore, we invoke this routine when we need to write a new relcache + * init file. + */ +void +InitCatalogCachePhase2(void) +{ + int cacheId; + + Assert(CacheInitialized); + + for (cacheId = 0; cacheId < SysCacheSize; cacheId++) + { + InitCatCachePhase2(SysCache[cacheId]); + } +} + + +/* * SearchSysCache * * A layer on top of SearchCatCache that does the initialization and |