diff options
| author | Tom Lane | 2006-05-03 22:45:26 +0000 |
|---|---|---|
| committer | Tom Lane | 2006-05-03 22:45:26 +0000 |
| commit | cb98e6fb8fd4f1ca955a85d5c0088e42e77a04f0 (patch) | |
| tree | 8b7aa603d809eb71b48b923a299189a54e4df544 /src/backend/postmaster | |
| parent | 5320c6cf6b21811eda1910a7df6f05b992fe2aea (diff) | |
Create a syscache for pg_database-indexed-by-oid, and make use of it
in various places that were previously doing ad hoc pg_database searches.
This may speed up database-related privilege checks a little bit, but
the main motivation is to eliminate the performance reason for having
ReverifyMyDatabase do such a lot of stuff (viz, avoiding repeat scans
of pg_database during backend startup). The locking reason for having
that routine is about to go away, and it'd be good to have the option
to break it up.
Diffstat (limited to 'src/backend/postmaster')
| -rw-r--r-- | src/backend/postmaster/autovacuum.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 4a5a05c1b28..a19e504b0ef 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.17 2006/04/27 15:57:10 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/postmaster/autovacuum.c,v 1.18 2006/05/03 22:45:26 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,6 +46,7 @@ #include "utils/memutils.h" #include "utils/ps_status.h" #include "utils/relcache.h" +#include "utils/syscache.h" /* @@ -493,9 +494,6 @@ autovac_get_database_list(void) static void process_whole_db(void) { - Relation dbRel; - ScanKeyData entry[1]; - SysScanDesc scan; HeapTuple tup; Form_pg_database dbForm; bool freeze; @@ -511,21 +509,12 @@ process_whole_db(void) */ pgstat_vacuum_tabstat(); - dbRel = heap_open(DatabaseRelationId, AccessShareLock); - - /* Must use a table scan, since there's no syscache for pg_database */ - ScanKeyInit(&entry[0], - ObjectIdAttributeNumber, - BTEqualStrategyNumber, F_OIDEQ, - ObjectIdGetDatum(MyDatabaseId)); - - scan = systable_beginscan(dbRel, DatabaseOidIndexId, true, - SnapshotNow, 1, entry); - - tup = systable_getnext(scan); - + /* Look up the pg_database entry and decide whether to FREEZE */ + tup = SearchSysCache(DATABASEOID, + ObjectIdGetDatum(MyDatabaseId), + 0, 0, 0); if (!HeapTupleIsValid(tup)) - elog(ERROR, "could not find tuple for database %u", MyDatabaseId); + elog(ERROR, "cache lookup failed for database %u", MyDatabaseId); dbForm = (Form_pg_database) GETSTRUCT(tup); @@ -534,9 +523,7 @@ process_whole_db(void) else freeze = false; - systable_endscan(scan); - - heap_close(dbRel, AccessShareLock); + ReleaseSysCache(tup); elog(DEBUG2, "autovacuum: VACUUM%s whole database", (freeze) ? " FREEZE" : ""); |
