Re: where are the getting buf data from disk really done? - Mailing list pgsql-general

From Greg Smith
Subject Re: where are the getting buf data from disk really done?
Date
Msg-id 4BCD0C28.2010102@2ndquadrant.com
Whole thread Raw
In response to where are the getting buf data from disk really done?  (sunpeng <bluevaley@gmail.com>)
List pgsql-general
sunpeng wrote:
>
> I noticed at the function StartBufferIO() in bufmgr.c, there is no
> really getting buffer data from disk, only set InProgressBuf = buf;
> and return true;
> i wondered where is the getting buf data from disk really done?
> are there a background process to do this work? which function does
> this work?

That's done by ReadBuffer_common in that same bit of source code.  The
call to smgrread is the one that does the read from disk.  StartBufferIO
is actually part of the buffer allocation code, used to lock things so
that only one backend tries to read in a buffer that more than one might
want.  Some highlights of the main code path here:

ReadBuffer | ReadBufferExtended | ReadBufferWithoutRelcache
  ReadBuffer_common
    BufferAlloc
      StrategyGetBuffer
      StartBufferIO
    smgrread

There is no background process involved at any point here.  The only
background process related to the buffer cache in the current PostgreSQL
implementation alternates between writing out checkpoint data and
writing dirty buffers that haven't been used recently, in hopes of
speeding up the BufferAlloc section here.  Everything else is done
directly by the client backends.

--
Greg Smith  2ndQuadrant US  Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com   www.2ndQuadrant.us


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: where are the getting buf data from disk really done?
Next
From: John R Pierce
Date:
Subject: Re: Int64GetDatum