diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-12 20:53:31 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-08-12 20:53:31 +0000 |
commit | 04011cc97060798a5d28219b731b3603dd112ab6 (patch) | |
tree | 8d001affc00fefdccb7d0a400fc146d9da8ed6b2 /src/backend/utils/init/flatfiles.c | |
parent | a1f0c9bab99edc6029dee3bf702348aa7eab0099 (diff) |
Allow backends to start up without use of the flat-file copy of pg_database.
To make this work in the base case, pg_database now has a nailed-in-cache
relation descriptor that is initialized using hardwired knowledge in
relcache.c. This means pg_database is added to the set of relations that
need to have a Schema_pg_xxx macro maintained in pg_attribute.h. When this
path is taken, we'll have to do a seqscan of pg_database to find the row
we need.
In the normal case, we are able to do an indexscan to find the database's row
by name. This is made possible by storing a global relcache init file that
describes only the shared catalogs and their indexes (and therefore is usable
by all backends in any database). A new backend loads this cache file,
finds its database OID after an indexscan on pg_database, and then loads
the local relcache init file for that database.
This change should effectively eliminate number of databases as a factor
in backend startup time, even with large numbers of databases. However,
the real reason for doing it is as a first step towards getting rid of
the flat files altogether. There are still several other sub-projects
to be tackled before that can happen.
Diffstat (limited to 'src/backend/utils/init/flatfiles.c')
-rw-r--r-- | src/backend/utils/init/flatfiles.c | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/backend/utils/init/flatfiles.c b/src/backend/utils/init/flatfiles.c index ad9c46394ce..5a9c8bd47b3 100644 --- a/src/backend/utils/init/flatfiles.c +++ b/src/backend/utils/init/flatfiles.c @@ -23,7 +23,7 @@ * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.36 2009/01/01 17:23:51 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.37 2009/08/12 20:53:30 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,6 @@ #include "access/twophase_rmgr.h" #include "access/xact.h" #include "access/xlogutils.h" -#include "catalog/catalog.h" #include "catalog/pg_auth_members.h" #include "catalog/pg_authid.h" #include "catalog/pg_database.h" @@ -51,7 +50,6 @@ #include "storage/pmsignal.h" #include "utils/builtins.h" #include "utils/flatfiles.h" -#include "utils/relcache.h" #include "utils/resowner.h" #include "utils/tqual.h" @@ -171,14 +169,9 @@ name_okay(const char *str) * * A side effect is to determine the oldest database's datfrozenxid * so we can set or update the XID wrap limit. - * - * Also, if "startup" is true, we tell relcache.c to clear out the relcache - * init file in each database. That's a bit nonmodular, but scanning - * pg_database twice during system startup seems too high a price for keeping - * things better separated. */ static void -write_database_file(Relation drel, bool startup) +write_database_file(Relation drel) { char *filename, *tempname; @@ -259,17 +252,6 @@ write_database_file(Relation drel, bool startup) fputs_quote(datname, fp); fprintf(fp, " %u %u %u\n", datoid, dattablespace, datfrozenxid); - - /* - * Also clear relcache init file for each DB if starting up. - */ - if (startup) - { - char *dbpath = GetDatabasePath(datoid, dattablespace); - - RelationCacheInitFileRemove(dbpath); - pfree(dbpath); - } } heap_endscan(scan); @@ -688,9 +670,6 @@ write_auth_file(Relation rel_authid, Relation rel_authmem) * policy means we need not force initdb to change the format of the * flat files. * - * We also cause relcache init files to be flushed, for largely the same - * reasons. - * * In a standalone backend we pass database_only = true to skip processing * the auth file. We won't need it, and building it could fail if there's * something corrupt in the authid/authmem catalogs. @@ -720,7 +699,7 @@ BuildFlatFiles(bool database_only) * No locking is needed because no one else is alive yet. */ rel_db = CreateFakeRelcacheEntry(rnode); - write_database_file(rel_db, true); + write_database_file(rel_db); FreeFakeRelcacheEntry(rel_db); if (!database_only) @@ -833,7 +812,7 @@ AtEOXact_UpdateFlatFiles(bool isCommit) if (database_file_update_subid != InvalidSubTransactionId) { database_file_update_subid = InvalidSubTransactionId; - write_database_file(drel, false); + write_database_file(drel); heap_close(drel, NoLock); } |