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

Commit4ce4d7f

Browse files
committed
Rearrange heap_beginscan to eliminate extra call on
mdnblocks. Bad enough it does an lseek, but to do it twice for noreason...
1 parent57ea208 commit4ce4d7f

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.56 1999/10/11 06:28:27 inoue Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.57 1999/10/30 23:10:21 tgl Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -102,7 +102,16 @@ initscan(HeapScanDesc scan,
102102
unsigned nkeys,
103103
ScanKey key)
104104
{
105-
if (!RelationGetNumberOfBlocks(relation))
105+
/* ----------------
106+
*Make sure we have up-to-date idea of number of blocks in relation.
107+
*It is sufficient to do this once at scan start, since any tuples
108+
*added while the scan is in progress will be invisible to my
109+
*transaction anyway...
110+
* ----------------
111+
*/
112+
relation->rd_nblocks = RelationGetNumberOfBlocks(relation);
113+
114+
if (relation->rd_nblocks == 0)
106115
{
107116
/* ----------------
108117
*relation is empty
@@ -652,11 +661,12 @@ heap_beginscan(Relation relation,
652661
*/
653662
scan = (HeapScanDesc) palloc(sizeof(HeapScanDescData));
654663

655-
relation->rd_nblocks = smgrnblocks(DEFAULT_SMGR, relation);
656664
scan->rs_rd = relation;
665+
scan->rs_atend = atend;
666+
scan->rs_snapshot = snapshot;
667+
scan->rs_nkeys = (short) nkeys;
657668

658669
if (nkeys)
659-
660670
/*
661671
* we do this here instead of in initscan() because heap_rescan
662672
* also calls initscan() and we don't want to allocate memory
@@ -668,10 +678,6 @@ heap_beginscan(Relation relation,
668678

669679
initscan(scan, relation, atend, nkeys, key);
670680

671-
scan->rs_atend = atend;
672-
scan->rs_snapshot = snapshot;
673-
scan->rs_nkeys = (short) nkeys;
674-
675681
return scan;
676682
}
677683

@@ -703,8 +709,8 @@ heap_rescan(HeapScanDesc scan,
703709
*reinitialize scan descriptor
704710
* ----------------
705711
*/
706-
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
707712
scan->rs_atend = (bool) scanFromEnd;
713+
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
708714
}
709715

710716
/* ----------------
@@ -1096,7 +1102,7 @@ heap_get_latest_tid(Relation relation,
10961102
Snapshot snapshot,
10971103
ItemPointer tid)
10981104
{
1099-
ItemIdlp;
1105+
ItemIdlp = NULL;
11001106
Bufferbuffer;
11011107
PageHeaderdp;
11021108
OffsetNumberoffnum;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp