1
0
mirror of https://github.com/postgres/postgres.git synced 2025-10-24 01:29:19 +03:00

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).
This commit is contained in:
Tom Lane
2002-02-19 20:11:20 +00:00
parent 8e2998d8a6
commit 7863404417
33 changed files with 1997 additions and 2220 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: genam.h,v 1.31 2001/11/05 17:46:31 momjian Exp $
* $Id: genam.h,v 1.32 2002/02/19 20:11:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,9 +31,23 @@ typedef struct IndexBulkDeleteResult
typedef bool (*IndexBulkDeleteCallback) (ItemPointer itemptr, void *state);
/* ----------------
* generalized index_ interface routines (in indexam.c)
* ----------------
/* Struct for heap-or-index scans of system tables */
typedef struct SysScanDescData
{
Relation heap_rel; /* catalog being scanned */
Snapshot snapshot; /* time qual (normally SnapshotNow) */
Relation irel; /* NULL if doing heap scan */
HeapScanDesc scan; /* only valid in heap-scan case */
IndexScanDesc iscan; /* only valid in index-scan case */
HeapTupleData tuple; /* workspace for indexscan */
Buffer buffer; /* working state for indexscan */
} SysScanDescData;
typedef SysScanDescData *SysScanDesc;
/*
* generalized index_ interface routines (in indexam.c)
*/
extern Relation index_open(Oid relationId);
extern Relation index_openr(const char *relationName);
@@ -59,9 +73,22 @@ extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum,
extern struct FmgrInfo *index_getprocinfo(Relation irel, AttrNumber attnum,
uint16 procnum);
/* in genam.c */
/*
* index access method support routines (in genam.c)
*/
extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd,
uint16 numberOfKeys, ScanKey key);
extern void IndexScanEnd(IndexScanDesc scan);
/*
* heap-or-index access to system catalogs (in genam.c)
*/
extern SysScanDesc systable_beginscan(Relation rel,
const char *indexRelname,
bool indexOK,
Snapshot snapshot,
unsigned nkeys, ScanKey key);
extern HeapTuple systable_getnext(SysScanDesc sysscan);
extern void systable_endscan(SysScanDesc sysscan);
#endif /* GENAM_H */

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: istrat.h,v 1.23 2001/11/05 17:46:31 momjian Exp $
* $Id: istrat.h,v 1.24 2002/02/19 20:11:19 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -47,6 +47,8 @@
*/
#define IndexStrategyIsValid(s) PointerIsValid(s)
extern ScanKey StrategyMapGetScanKeyEntry(StrategyMap map,
StrategyNumber strategyNumber);
extern StrategyMap IndexStrategyGetStrategyMap(IndexStrategy indexStrategy,
StrategyNumber maxStrategyNum, AttrNumber attrNum);
@@ -55,13 +57,5 @@ extern Size AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber,
extern StrategyNumber RelationGetStrategy(Relation relation,
AttrNumber attributeNumber, StrategyEvaluation evaluation,
RegProcedure procedure);
extern void IndexSupportInitialize(IndexStrategy indexStrategy,
RegProcedure *indexSupport,
bool *isUnique,
Oid indexObjectId,
Oid accessMethodObjectId,
StrategyNumber maxStrategyNumber,
StrategyNumber maxSupportNumber,
AttrNumber maxAttributeNumber);
#endif /* ISTRAT_H */