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

Commit973a210

Browse files
committed
Tweak mdnblocks() to avoid doing lseek() on segments that it has
previously determined not to be the last segment of a relation.This reduces the expected cost to one seek, rather than one seek persegment. We can get away with this because truncation of a relationwill cause a relcache flush and so the md.c file descriptor will beclosed; when it is re-opened we will re-determine the last segment.
1 parentc9cf982 commit973a210

File tree

1 file changed

+16
-1
lines changed
  • src/backend/storage/smgr

1 file changed

+16
-1
lines changed

‎src/backend/storage/smgr/md.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.93 2002/11/12 15:26:30 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.94 2003/01/07 01:19:12 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -569,6 +569,21 @@ mdnblocks(Relation reln)
569569

570570
#ifndefLET_OS_MANAGE_FILESIZE
571571
segno=0;
572+
573+
/*
574+
* Skip through any segments that aren't the last one, to avoid redundant
575+
* seeks on them. We have previously verified that these segments are
576+
* exactly RELSEG_SIZE long, and it's useless to recheck that each time.
577+
* (NOTE: this assumption could only be wrong if another backend has
578+
* truncated the relation. We rely on higher code levels to handle that
579+
* scenario by closing and re-opening the md fd.)
580+
*/
581+
while (v->mdfd_chain!= (MdfdVec*)NULL)
582+
{
583+
segno++;
584+
v=v->mdfd_chain;
585+
}
586+
572587
for (;;)
573588
{
574589
nblocks=_mdnblocks(v->mdfd_vfd,BLCKSZ);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp