1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +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

@@ -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);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.153 2002/02/14 15:24:06 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.154 2002/02/19 20:11:12 tgl Exp $
*
* NOTES
* The PerformAddAttribute() code, like most of the relation
@@ -29,6 +29,7 @@
#include "catalog/pg_attrdef.h"
#include "catalog/pg_index.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_relcheck.h"
#include "catalog/pg_type.h"
#include "commands/command.h"
#include "commands/trigger.h"
@@ -820,92 +821,8 @@ AlterTableAlterColumnStatistics(const char *relationName,
#ifdef _DROP_COLUMN_HACK__
/*
* ALTER TABLE DROP COLUMN trial implementation
*
*/
/*
* system table scan(index scan/sequential scan)
*/
typedef struct SysScanDescData
{
Relation heap_rel;
Relation irel;
HeapScanDesc scan;
IndexScanDesc iscan;
HeapTupleData tuple;
Buffer buffer;
} SysScanDescData, *SysScanDesc;
static void *
systable_beginscan(Relation rel, const char *indexRelname, int nkeys, ScanKey entry)
{
bool hasindex = (rel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
SysScanDesc sysscan;
sysscan = (SysScanDesc) palloc(sizeof(SysScanDescData));
sysscan->heap_rel = rel;
sysscan->irel = (Relation) NULL;
sysscan->tuple.t_datamcxt = NULL;
sysscan->tuple.t_data = NULL;
sysscan->buffer = InvalidBuffer;
if (hasindex)
{
sysscan->irel = index_openr((char *) indexRelname);
sysscan->iscan = index_beginscan(sysscan->irel, false, nkeys, entry);
}
else
sysscan->scan = heap_beginscan(rel, false, SnapshotNow, nkeys, entry);
return (void *) sysscan;
}
static void
systable_endscan(void *scan)
{
SysScanDesc sysscan = (SysScanDesc) scan;
if (sysscan->irel)
{
if (BufferIsValid(sysscan->buffer))
ReleaseBuffer(sysscan->buffer);
index_endscan(sysscan->iscan);
index_close(sysscan->irel);
}
else
heap_endscan(sysscan->scan);
pfree(scan);
}
static HeapTuple
systable_getnext(void *scan)
{
SysScanDesc sysscan = (SysScanDesc) scan;
HeapTuple htup = (HeapTuple) NULL;
RetrieveIndexResult indexRes;
if (sysscan->irel)
{
if (BufferIsValid(sysscan->buffer))
{
ReleaseBuffer(sysscan->buffer);
sysscan->buffer = InvalidBuffer;
}
while (indexRes = index_getnext(sysscan->iscan, ForwardScanDirection), indexRes != NULL)
{
sysscan->tuple.t_self = indexRes->heap_iptr;
heap_fetch(sysscan->heap_rel, SnapshotNow, &sysscan->tuple, &(sysscan->buffer));
pfree(indexRes);
if (sysscan->tuple.t_data != NULL)
{
htup = &sysscan->tuple;
break;
}
}
}
else
htup = heap_getnext(sysscan->scan, 0);
return htup;
}
/*
* find a specified attribute in a node entry
*/
@@ -957,10 +874,15 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
/*
* Remove/check constraints here
*/
ScanKeyEntryInitialize(&entry, (bits16) 0x0, Anum_pg_relcheck_rcrelid,
(RegProcedure) F_OIDEQ, ObjectIdGetDatum(reloid));
ScanKeyEntryInitialize(&entry, (bits16) 0x0,
Anum_pg_relcheck_rcrelid,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(reloid));
rcrel = heap_openr(RelCheckRelationName, RowExclusiveLock);
sysscan = systable_beginscan(rcrel, RelCheckIndex, 1, &entry);
sysscan = systable_beginscan(rcrel, RelCheckIndex, true,
SnapshotNow,
1, &entry);
while (HeapTupleIsValid(htup = systable_getnext(sysscan)))
{
@@ -987,6 +909,7 @@ RemoveColumnReferences(Oid reloid, int attnum, bool checkonly, HeapTuple reltup)
}
}
}
systable_endscan(sysscan);
heap_close(rcrel, NoLock);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.101 2002/01/15 16:52:47 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.102 2002/02/19 20:11:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -56,7 +56,7 @@ CreateTrigger(CreateTrigStmt *stmt)
char nulls[Natts_pg_trigger];
Relation rel;
Relation tgrel;
HeapScanDesc tgscan;
SysScanDesc tgscan;
ScanKeyData key;
Relation pgrel;
HeapTuple tuple;
@@ -151,8 +151,9 @@ CreateTrigger(CreateTrigStmt *stmt)
ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = heap_getnext(tgscan, 0)))
tgscan = systable_beginscan(tgrel, TriggerRelidIndex, true,
SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
@@ -161,7 +162,7 @@ CreateTrigger(CreateTrigStmt *stmt)
stmt->trigname, stmt->relname);
found++;
}
heap_endscan(tgscan);
systable_endscan(tgscan);
/*
* Find and validate the trigger function.
@@ -311,7 +312,7 @@ DropTrigger(DropTrigStmt *stmt)
{
Relation rel;
Relation tgrel;
HeapScanDesc tgscan;
SysScanDesc tgscan;
ScanKeyData key;
Relation pgrel;
HeapTuple tuple;
@@ -343,8 +344,9 @@ DropTrigger(DropTrigStmt *stmt)
ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = heap_getnext(tgscan, 0)))
tgscan = systable_beginscan(tgrel, TriggerRelidIndex, true,
SnapshotNow, 1, &key);
while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
@@ -359,14 +361,15 @@ DropTrigger(DropTrigStmt *stmt)
else
found++;
}
systable_endscan(tgscan);
heap_close(tgrel, RowExclusiveLock);
if (tgfound == 0)
elog(ERROR, "DropTrigger: there is no trigger %s on relation %s",
stmt->trigname, stmt->relname);
if (tgfound > 1)
elog(NOTICE, "DropTrigger: found (and deleted) %d triggers %s on relation %s",
tgfound, stmt->trigname, stmt->relname);
heap_endscan(tgscan);
heap_close(tgrel, RowExclusiveLock);
/*
* Update relation's pg_class entry. Crucial side-effect: other
@@ -406,7 +409,7 @@ void
RelationRemoveTriggers(Relation rel)
{
Relation tgrel;
HeapScanDesc tgscan;
SysScanDesc tgscan;
ScanKeyData key;
HeapTuple tup;
bool found = false;
@@ -415,10 +418,10 @@ RelationRemoveTriggers(Relation rel)
ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgrelid,
F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
tgscan = systable_beginscan(tgrel, TriggerRelidIndex, true,
SnapshotNow, 1, &key);
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
while (HeapTupleIsValid(tup = systable_getnext(tgscan)))
{
/* Delete any comments associated with this trigger */
DeleteComments(tup->t_data->t_oid, RelationGetRelid(tgrel));
@@ -428,7 +431,7 @@ RelationRemoveTriggers(Relation rel)
found = true;
}
heap_endscan(tgscan);
systable_endscan(tgscan);
/*
* If we deleted any triggers, must update pg_class entry and advance
@@ -468,9 +471,10 @@ RelationRemoveTriggers(Relation rel)
ScanKeyEntryInitialize(&key, 0, Anum_pg_trigger_tgconstrrelid,
F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(rel)));
tgscan = systable_beginscan(tgrel, TriggerConstrRelidIndex, true,
SnapshotNow, 1, &key);
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
while (HeapTupleIsValid(tup = systable_getnext(tgscan)))
{
Form_pg_trigger pg_trigger;
Relation refrel;
@@ -500,7 +504,7 @@ RelationRemoveTriggers(Relation rel)
pfree(stmt.relname);
pfree(stmt.trigname);
}
heap_endscan(tgscan);
systable_endscan(tgscan);
heap_close(tgrel, RowExclusiveLock);
}
@@ -518,69 +522,33 @@ RelationBuildTriggers(Relation relation)
TriggerDesc *trigdesc;
int ntrigs = relation->rd_rel->reltriggers;
Trigger *triggers = NULL;
Trigger *build;
int found = 0;
Relation tgrel;
Form_pg_trigger pg_trigger;
Relation irel = (Relation) NULL;
ScanKeyData skey;
HeapTupleData tuple;
IndexScanDesc sd = (IndexScanDesc) NULL;
HeapScanDesc tgscan = (HeapScanDesc) NULL;
SysScanDesc tgscan;
HeapTuple htup;
RetrieveIndexResult indexRes;
Buffer buffer;
struct varlena *val;
bool isnull;
int found;
bool hasindex;
trigdesc = (TriggerDesc *) MemoryContextAlloc(CacheMemoryContext,
sizeof(TriggerDesc));
MemSet(trigdesc, 0, sizeof(TriggerDesc));
ScanKeyEntryInitialize(&skey,
(bits16) 0x0,
(AttrNumber) 1,
(AttrNumber) Anum_pg_trigger_tgrelid,
(RegProcedure) F_OIDEQ,
ObjectIdGetDatum(RelationGetRelid(relation)));
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
hasindex = (tgrel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
if (hasindex)
{
irel = index_openr(TriggerRelidIndex);
sd = index_beginscan(irel, false, 1, &skey);
}
else
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &skey);
tgscan = systable_beginscan(tgrel, TriggerRelidIndex, true,
SnapshotNow, 1, &skey);
for (found = 0;;)
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
if (hasindex)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
Trigger *build;
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (!tuple.t_data)
continue;
htup = &tuple;
}
else
{
htup = heap_getnext(tgscan, 0);
if (!HeapTupleIsValid(htup))
break;
}
if (found == ntrigs)
elog(ERROR, "RelationBuildTriggers: unexpected record found for rel %s",
RelationGetRelationName(relation));
pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
if (triggers == NULL)
triggers = (Trigger *) MemoryContextAlloc(CacheMemoryContext,
sizeof(Trigger));
@@ -628,25 +596,20 @@ RelationBuildTriggers(Relation relation)
build->tgargs = NULL;
found++;
if (hasindex)
ReleaseBuffer(buffer);
}
if (found < ntrigs)
systable_endscan(tgscan);
heap_close(tgrel, AccessShareLock);
if (found != ntrigs)
elog(ERROR, "RelationBuildTriggers: %d record(s) not found for rel %s",
ntrigs - found,
RelationGetRelationName(relation));
if (hasindex)
{
index_endscan(sd);
index_close(irel);
}
else
heap_endscan(tgscan);
heap_close(tgrel, AccessShareLock);
/* Build trigdesc */
trigdesc = (TriggerDesc *) MemoryContextAlloc(CacheMemoryContext,
sizeof(TriggerDesc));
MemSet(trigdesc, 0, sizeof(TriggerDesc));
trigdesc->triggers = triggers;
trigdesc->numtriggers = ntrigs;
for (found = 0; found < ntrigs; found++)
@@ -1741,14 +1704,12 @@ void
DeferredTriggerSetState(ConstraintsSetStmt *stmt)
{
Relation tgrel;
Relation irel = (Relation) NULL;
List *l;
List *ls;
List *loid = NIL;
MemoryContext oldcxt;
bool found;
DeferredTriggerStatus state;
bool hasindex;
/*
* Handle SET CONSTRAINTS ALL ...
@@ -1817,21 +1778,12 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
* ----------
*/
tgrel = heap_openr(TriggerRelationName, AccessShareLock);
hasindex = (tgrel->rd_rel->relhasindex && !IsIgnoringSystemIndexes());
if (hasindex)
irel = index_openr(TriggerConstrNameIndex);
foreach(l, stmt->constraints)
{
ScanKeyData skey;
HeapTupleData tuple;
IndexScanDesc sd = (IndexScanDesc) NULL;
HeapScanDesc tgscan = (HeapScanDesc) NULL;
SysScanDesc tgscan;
HeapTuple htup;
RetrieveIndexResult indexRes;
Buffer buffer;
Form_pg_trigger pg_trigger;
Oid constr_oid;
/*
* Check that only named constraints are set explicitly
@@ -1844,47 +1796,28 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
*/
ScanKeyEntryInitialize(&skey,
(bits16) 0x0,
(AttrNumber) 1,
(AttrNumber) Anum_pg_trigger_tgconstrname,
(RegProcedure) F_NAMEEQ,
PointerGetDatum((char *) lfirst(l)));
if (hasindex)
sd = index_beginscan(irel, false, 1, &skey);
else
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &skey);
tgscan = systable_beginscan(tgrel, TriggerConstrNameIndex, true,
SnapshotNow, 1, &skey);
/*
* ... and search for the constraint trigger row
*/
found = false;
for (;;)
{
if (hasindex)
{
indexRes = index_getnext(sd, ForwardScanDirection);
if (!indexRes)
break;
tuple.t_self = indexRes->heap_iptr;
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (!tuple.t_data)
continue;
htup = &tuple;
}
else
{
htup = heap_getnext(tgscan, 0);
if (!HeapTupleIsValid(htup))
break;
}
while (HeapTupleIsValid(htup = systable_getnext(tgscan)))
{
Form_pg_trigger pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
Oid constr_oid;
/*
* If we found some, check that they fit the deferrability but
* skip ON <event> RESTRICT ones, since they are silently
* never deferrable.
*/
pg_trigger = (Form_pg_trigger) GETSTRUCT(htup);
if (stmt->deferred && !pg_trigger->tgdeferrable &&
pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD &&
pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_DEL)
@@ -1894,24 +1827,16 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
constr_oid = htup->t_data->t_oid;
loid = lappendi(loid, constr_oid);
found = true;
if (hasindex)
ReleaseBuffer(buffer);
}
systable_endscan(tgscan);
/*
* Not found ?
*/
if (!found)
elog(ERROR, "Constraint '%s' does not exist", (char *) lfirst(l));
if (hasindex)
index_endscan(sd);
else
heap_endscan(tgscan);
}
if (hasindex)
index_close(irel);
heap_close(tgrel, AccessShareLock);
if (!IsTransactionBlock())

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.213 2002/01/06 00:37:44 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.214 2002/02/19 20:11:12 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -315,20 +315,6 @@ vacuum_shutdown(VacuumStmt *vacstmt)
vac_truncate_clog(initialOldestXmin, initialFreezeLimit);
}
/*
* If we did a complete vacuum or analyze, then flush the init file
* that relcache.c uses to save startup time. The next backend startup
* will rebuild the init file with up-to-date information from
* pg_class. This lets the optimizer see the stats that we've
* collected for certain critical system indexes. See relcache.c for
* more details.
*
* Ignore any failure to unlink the file, since it might not be there if
* no backend has been started since the last vacuum.
*/
if (vacstmt->vacrel == NULL)
unlink(RELCACHE_INIT_FILENAME);
/*
* Clean up working storage --- note we must do this after
* StartTransactionCommand, else we might be trying to delete the
@@ -535,8 +521,15 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples,
if (!hasindex)
pgcform->relhaspkey = false;
/* invalidate the tuple in the cache and write the buffer */
/*
* Invalidate the tuple in the catcaches; this also arranges to flush
* the relation's relcache entry. (If we fail to commit for some reason,
* no flush will occur, but no great harm is done since there are no
* noncritical state updates here.)
*/
RelationInvalidateHeapTuple(rd, &rtup);
/* Write the buffer */
WriteBuffer(buffer);
heap_close(rd, RowExclusiveLock);
@@ -2816,10 +2809,6 @@ vac_close_indexes(int nindexes, Relation *Irel)
bool
vac_is_partial_index(Relation indrel)
{
bool result;
HeapTuple cachetuple;
Form_pg_index indexStruct;
/*
* If the index's AM doesn't support nulls, it's partial for our
* purposes
@@ -2828,18 +2817,7 @@ vac_is_partial_index(Relation indrel)
return true;
/* Otherwise, look to see if there's a partial-index predicate */
cachetuple = SearchSysCache(INDEXRELID,
ObjectIdGetDatum(RelationGetRelid(indrel)),
0, 0, 0);
if (!HeapTupleIsValid(cachetuple))
elog(ERROR, "vac_is_partial_index: index %u not found",
RelationGetRelid(indrel));
indexStruct = (Form_pg_index) GETSTRUCT(cachetuple);
result = (VARSIZE(&indexStruct->indpred) > VARHDRSZ);
ReleaseSysCache(cachetuple);
return result;
return (VARSIZE(&indrel->rd_index->indpred) > VARHDRSZ);
}