Skip to content

Commit 009d593

Browse files
committed
Small performance improvement --- use indexscan not heapscan to find
pg_statistic rows to delete while dropping a relation.
1 parent 59a471f commit 009d593

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/backend/catalog/heap.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.210 2002/07/18 16:47:22 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.211 2002/07/19 22:21:17 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -793,7 +793,8 @@ heap_create_with_catalog(const char *relname,
793793
* Formerly, this routine checked for child relations and aborted the
794794
* deletion if any were found. Now we rely on the dependency mechanism
795795
* to check for or delete child relations. By the time we get here,
796-
* there are no children and we need only remove the pg_inherits rows.
796+
* there are no children and we need only remove any pg_inherits rows
797+
* linking this relation to its parent(s).
797798
*/
798799
static void
799800
RelationRemoveInheritance(Relation relation)
@@ -1743,21 +1744,25 @@ static void
17431744
RemoveStatistics(Relation rel)
17441745
{
17451746
Relation pgstatistic;
1746-
HeapScanDesc scan;
1747+
SysScanDesc scan;
17471748
ScanKeyData key;
17481749
HeapTuple tuple;
17491750

17501751
pgstatistic = heap_openr(StatisticRelationName, RowExclusiveLock);
17511752

1752-
ScanKeyEntryInitialize(&key, 0x0, Anum_pg_statistic_starelid,
1753-
F_OIDEQ,
1753+
ScanKeyEntryInitialize(&key, 0x0,
1754+
Anum_pg_statistic_starelid, F_OIDEQ,
17541755
ObjectIdGetDatum(RelationGetRelid(rel)));
1755-
scan = heap_beginscan(pgstatistic, SnapshotNow, 1, &key);
17561756

1757-
while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL)
1757+
scan = systable_beginscan(pgstatistic, StatisticRelidAttnumIndex, true,
1758+
SnapshotNow, 1, &key);
1759+
1760+
while (HeapTupleIsValid(tuple = systable_getnext(scan)))
1761+
{
17581762
simple_heap_delete(pgstatistic, &tuple->t_self);
1763+
}
17591764

1760-
heap_endscan(scan);
1765+
systable_endscan(scan);
17611766
heap_close(pgstatistic, RowExclusiveLock);
17621767
}
17631768

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy