aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-02-19 20:11:20 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-02-19 20:11:20 +0000
commit786340441706ac1957a031f11ad1c2e5b6e18314 (patch)
tree4e6b689b96778e42e6cc679169f71dc180049e04 /src/backend/utils/init/postinit.c
parent8e2998d8a6aebc2a3b22e6048fab8abe1c95f1f0 (diff)
downloadpostgresql-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/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 3a48b133bfe..222ab6d54ab 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.97 2001/11/02 16:30:29 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.98 2002/02/19 20:11:18 tgl Exp $
*
*
*-------------------------------------------------------------------------
@@ -287,16 +287,15 @@ InitPostgres(const char *dbname, const char *username)
AmiTransactionOverride(bootstrap);
/*
- * Initialize the relation descriptor cache. The pre-allocated
- * reldescs are created here.
+ * Initialize the relation descriptor cache. This must create
+ * at least the minimum set of "nailed-in" cache entries. No
+ * catalog access happens here.
*/
RelationCacheInitialize();
/*
- * Initialize all the system catalog caches.
- *
- * Does not touch files since all routines are builtins (?) - thomas
- * 1997-11-01
+ * Initialize all the system catalog caches. Note that no catalog
+ * access happens here; we only set up the cache structure.
*/
InitCatalogCache();
@@ -313,7 +312,11 @@ InitPostgres(const char *dbname, const char *username)
if (!bootstrap)
StartTransactionCommand();
- /* replace faked-up relcache entries with the real info */
+ /*
+ * It's now possible to do real access to the system catalogs.
+ *
+ * Replace faked-up relcache entries with correct info.
+ */
RelationCacheInitializePhase2();
/*
@@ -333,8 +336,10 @@ InitPostgres(const char *dbname, const char *username)
}
}
else
+ {
/* normal multiuser case */
InitializeSessionUserId(username);
+ }
/*
* Unless we are bootstrapping, double-check that InitMyDatabaseInfo()
@@ -350,6 +355,13 @@ InitPostgres(const char *dbname, const char *username)
#endif
/*
+ * Final phase of relation cache startup: write a new cache file
+ * if necessary. This is done after ReverifyMyDatabase to avoid
+ * writing a cache file into a dead database.
+ */
+ RelationCacheInitializePhase3();
+
+ /*
* Set up process-exit callbacks to remove temp relations and then do
* pre-shutdown cleanup. This should be last because we want
* shmem_exit to call these routines before the exit callbacks that