Re: [GENERAL] pg_buffercache view

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: "Sorin N(dot) Ciolofan" <ciolofan(at)ics(dot)forth(dot)gr>
Cc: <pgsql-general(at)postgresql(dot)org>, <pgsql-admin(at)postgresql(dot)org>
Subject: Re: [GENERAL] pg_buffercache view
Date: 2007-04-26 13:28:57
Message-ID: 20070426092857.82e2da22.wmoran@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

In response to "Sorin N. Ciolofan" <ciolofan(at)ics(dot)forth(dot)gr>:
>
> I don't know the algorithm on which Postgre uses the shared buffers but I'd
> like to find the principles behind it. Let's assume the following scenario:
> I've set shared_buffers=3000
> At the starting of Postgres there are 115 buffers used by database A
> After the execution of some processing caused by a java methodA1()
> invocation, 2850 buffers are used by A.
> What happens next if these 2850 buffers remains used even if the methodA1()
> finished its execution?

They'll be reused the next time a query needs the same data, or discarded
when the buffer space is needed for something else.

> Suppose that now a methodA2() invocation occurs and this method works with
> database A, too. Will be the 2850 buffers reused

yes

> or will postgre throw an
> "out of shared memory" exception?

no

> What happens if a methodB() invocation occurs, assuming that this method
> tries to work with database B?

Buffers will be allocated/reallocate/reused as best fits the usage pattern
of the server.

> How Postgres decides the allocation of shared_buffers?

They're "buffers".

They follow the design of just about any other type of buffer:
http://foldoc.org/index.cgi?query=buffer&action=Search

"Buffers are used to decouple processes so that the reader and writer may
operate at different speeds or on different sized blocks of data."

> -----Original Message-----
> From: pgsql-general-owner(at)postgresql(dot)org
> [mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Bill Moran
> Sent: Thursday, April 26, 2007 3:32 PM
> To: Sorin N. Ciolofan
> Cc: pgsql-general(at)postgresql(dot)org; pgsql-admin(at)postgresql(dot)org
> Subject: Re: [ADMIN] [GENERAL] pg_buffercache view
>
> In response to "Sorin N. Ciolofan" <ciolofan(at)ics(dot)forth(dot)gr>:
>
> >
> > Hello!
> >
> > Do you know which could be the reasons that could conduce an application
> to
> > not release the shared buffers, even after the application was shut down?
> > I noticed that only if a pg_ctl restart command is issued some of the
> > buffers are set free.
>
> The reason would be "by design."
>
> If the server flushes its cache every time the application restarts, the
> cache isn't going to be very effective.
>
> If PostgreSQL is using more shared buffers than you're comfortable with,
> reduce the shared_buffers setting in the config. That will allow the OS
> to decide how to use the memory instead.
>
> --
> Bill Moran
> http://www.potentialtech.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org/
>
>

--
Bill Moran
http://www.potentialtech.com

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Martial Elise KIBA 2007-04-27 11:50:57 PostgreSQL8.2.3 Performance
Previous Message Sorin N. Ciolofan 2007-04-26 13:05:14 Re: [GENERAL] pg_buffercache view

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2007-04-26 13:29:25 Re: Feature request - have postgresql log warning when new sub-release comes out.
Previous Message Sim Zacks 2007-04-26 13:09:05 Re: [pgadmin-support] questions about cursors