aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/cluster.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/commands/cluster.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/commands/cluster.c')
-rw-r--r--src/backend/commands/cluster.c41
1 files changed, 7 insertions, 34 deletions
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 663a2b22008..f3739487426 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.71 2002/01/06 00:37:44 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.72 2002/02/19 20:11:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -61,7 +61,6 @@ cluster(char *oldrelname, char *oldindexname)
OIDNewHeap;
Relation OldHeap,
OldIndex;
- HeapTuple tuple;
bool istemp;
char NewHeapName[NAMEDATALEN];
char NewIndexName[NAMEDATALEN];
@@ -90,16 +89,9 @@ cluster(char *oldrelname, char *oldindexname)
/*
* Check that index is in fact an index on the given relation
*/
- tuple = SearchSysCache(INDEXRELID,
- ObjectIdGetDatum(OIDOldIndex),
- 0, 0, 0);
- if (!HeapTupleIsValid(tuple))
- elog(ERROR, "CLUSTER: no pg_index entry for index %u",
- OIDOldIndex);
- if (((Form_pg_index) GETSTRUCT(tuple))->indrelid != OIDOldHeap)
+ if (OldIndex->rd_index->indrelid != OIDOldHeap)
elog(ERROR, "CLUSTER: \"%s\" is not an index for table \"%s\"",
saveoldindexname, saveoldrelname);
- ReleaseSysCache(tuple);
/* Drop relcache refcnts, but do NOT give up the locks */
heap_close(OldHeap, NoLock);
@@ -188,10 +180,6 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName)
{
Relation OldIndex,
NewHeap;
- HeapTuple Old_pg_index_Tuple,
- Old_pg_index_relation_Tuple;
- Form_pg_index Old_pg_index_Form;
- Form_pg_class Old_pg_index_relation_Form;
IndexInfo *indexInfo;
NewHeap = heap_open(OIDNewHeap, AccessExclusiveLock);
@@ -206,33 +194,18 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap, char *NewIndexName)
* its parent table is, so we don't need to do anything special for
* the temp-table case here.
*/
- Old_pg_index_Tuple = SearchSysCache(INDEXRELID,
- ObjectIdGetDatum(OIDOldIndex),
- 0, 0, 0);
- Assert(Old_pg_index_Tuple);
- Old_pg_index_Form = (Form_pg_index) GETSTRUCT(Old_pg_index_Tuple);
-
- indexInfo = BuildIndexInfo(Old_pg_index_Tuple);
-
- Old_pg_index_relation_Tuple = SearchSysCache(RELOID,
- ObjectIdGetDatum(OIDOldIndex),
- 0, 0, 0);
- Assert(Old_pg_index_relation_Tuple);
- Old_pg_index_relation_Form = (Form_pg_class) GETSTRUCT(Old_pg_index_relation_Tuple);
+ indexInfo = BuildIndexInfo(OldIndex->rd_index);
index_create(RelationGetRelationName(NewHeap),
NewIndexName,
indexInfo,
- Old_pg_index_relation_Form->relam,
- Old_pg_index_Form->indclass,
- Old_pg_index_Form->indisprimary,
+ OldIndex->rd_rel->relam,
+ OldIndex->rd_index->indclass,
+ OldIndex->rd_index->indisprimary,
allowSystemTableMods);
setRelhasindex(OIDNewHeap, true,
- Old_pg_index_Form->indisprimary, InvalidOid);
-
- ReleaseSysCache(Old_pg_index_Tuple);
- ReleaseSysCache(Old_pg_index_relation_Tuple);
+ OldIndex->rd_index->indisprimary, InvalidOid);
index_close(OldIndex);
heap_close(NewHeap, NoLock);