Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit009d593

Browse files
committed
Small performance improvement --- use indexscan not heapscan to find
pg_statistic rows to delete while dropping a relation.
1 parent59a471f commit009d593

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
staticvoid
799800
RelationRemoveInheritance(Relationrelation)
@@ -1743,21 +1744,25 @@ static void
17431744
RemoveStatistics(Relationrel)
17441745
{
17451746
Relationpgstatistic;
1746-
HeapScanDescscan;
1747+
SysScanDescscan;
17471748
ScanKeyDatakey;
17481749
HeapTupletuple;
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)

[8]ページ先頭

©2009-2025 Movatter.jp