Re: Caching number of blocks in relation to avoi lseek. - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: Caching number of blocks in relation to avoi lseek.
Date
Msg-id 200006121805.OAA05626@candle.pha.pa.us
Whole thread Raw
In response to Caching number of blocks in relation to avoi lseek.  (Denis Perchine <dyp@perchine.com>)
Responses Re: Caching number of blocks in relation to avoi lseek.  (Denis Perchine <dyp@perchine.com>)
Re: Caching number of blocks in relation to avoi lseek.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> Hello all,
> 
> While digging the code I found out quite interesting comment in
> src/backend/access/heap/hio.c before function RelationPutHeapTupleAtEnd
> 
>  * Eventually, we should cache the number of blocks in a relation somewhere.
>  * Until that time, this code will have to do an lseek to determine the number
>  * of blocks in a relation.
> 
> As far as I can see there's field rd_nblocks in Relation.
> 
> Question: is this field properly updated? Could it be used instead of RelationGetNumberOfBlocks
> which calls lseek.

Probably should be kept up-to-date.  Currently only vacuum sets it.  It
would have to be kept up-to-date for every INSERT/UPDATE that adds a block.

--  Bruce Momjian                        |  http://www.op.net/~candle pgman@candle.pha.pa.us               |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Denis Perchine
Date:
Subject: Re: Patch for 'Not to stuff everything as files in a single directory, hash dirs'
Next
From: Denis Perchine
Date:
Subject: Re: Caching number of blocks in relation to avoi lseek.