Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8a59f33

Browse files
committed
Minor performance improvement in MultiRecordFreeSpace.
1 parent 7d4d5c0 commit 8a59f33

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/backend/storage/freespace/freespace.c

+16-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.3 2001/07/02 20:50:46 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.4 2001/07/19 21:25:37 tgl Exp $
1212
*
1313
*
1414
* NOTES:
@@ -419,9 +419,23 @@ MultiRecordFreeSpace(RelFileNode *rel,
419419
*
420420
* XXX we could probably be smarter about this than doing it
421421
* completely separately for each one. FIXME later.
422+
*
423+
* One thing we can do is short-circuit the process entirely if
424+
* a page (a) has too little free space to be recorded, and (b)
425+
* is within the minPage..maxPage range --- then we deleted any
426+
* old entry above, and we aren't going to make a new one.
427+
* This is particularly useful since in most cases, all the passed
428+
* pages will in fact be in the minPage..maxPage range.
422429
*/
423430
for (i = 0; i < nPages; i++)
424-
fsm_record_free_space(fsmrel, pages[i], spaceAvail[i]);
431+
{
432+
BlockNumber page = pages[i];
433+
Size avail = spaceAvail[i];
434+
435+
if (avail >= fsmrel->threshold ||
436+
page < minPage || page > maxPage)
437+
fsm_record_free_space(fsmrel, page, avail);
438+
}
425439
}
426440
SpinRelease(FreeSpaceLock);
427441
}

0 commit comments

Comments
 (0)