Re: Shared Buffer Size

From: Greg Smith <greg(at)2ndQuadrant(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Shared Buffer Size
Date: 2011-05-29 02:12:00
Message-ID: 4DE1AB70.2060601@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 05/27/2011 05:33 PM, preetika tyagi wrote:
> Hows does the shared buffer in Postgres rely on the Operating System
> cache?
> Suppose my RAM is 8 GB and shared_buffer is 24 MB in postgres. And
> there are some dirty pages in shared_buffer and I need to write a
> dirty page back to the disk to bring in a new page. What happens in
> this case? The dirty page will be written to the disk considering the
> shared_buffer size as 24 MB? or it will not be written and will stay
> in RAM which is 8 GB?
>

In this case, the dirty page will be written to the operating system,
which will initially store it in its own write cache. Eventually the
operating system will write that page out to disk from that cache. The
delay before that happens can easily be 30 seconds or more on operating
systems like Linux. If PostgreSQL needs to read that data again, it may
find it still in the OS cache, in which case the read will happen very
quickly. Eventually, the dirty data will be written to disk, and if
it's not used for long enough the OS cache memory will be re-used for
something else.

When you read a page into the database, and you don't dirty it, it might
be evicted from the database cache without a write. If the database
needs that page again, it will ask the OS for it. If the OS still has
it in its own read cache, it may just read it from the cache again,
without a real disk read happening.

--
Greg Smith 2ndQuadrant US greg(at)2ndQuadrant(dot)com Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2011-05-29 02:32:14 Re: How to check a table content efficiently? With LIMIT and OFFSET?
Previous Message Greg Smith 2011-05-29 02:05:46 Re: Shared Buffer Size