X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 2272CDACEA for ; Mon, 24 Oct 2005 12:09:58 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 52045-03 for ; Mon, 24 Oct 2005 15:09:56 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 0A496DACF4 for ; Mon, 24 Oct 2005 12:09:55 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 71so498833wra for ; Mon, 24 Oct 2005 08:09:55 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=QQfQmex45J/TldnqVsds03ZEuUansP8+ptNic5oXJq0CCkIHnE82oLSlvKGL7yUerS4x5x9XmR/aFthgAJTx5IzNpDDpXEXerFWYrSUnKH7Y0lyEMtlTElAZsUjRTeiWp3IelB7+2esqLDJjxY1x9Vayc6Eph+lDa3/Wy7QPHoE= Received: by 10.54.77.5 with SMTP id z5mr1891516wra; Mon, 24 Oct 2005 08:09:55 -0700 (PDT) Received: by 10.54.84.8 with HTTP; Mon, 24 Oct 2005 08:09:55 -0700 (PDT) Message-ID: <33c6269f0510240809k47f91a71t387a0b5ab0339f4c@mail.gmail.com> Date: Mon, 24 Oct 2005 11:09:55 -0400 From: Alex Turner To: Neil Conway Subject: Re: What gets cached? Cc: Martin Nickel , pgsql-performance@postgresql.org In-Reply-To: <1129931087.19971.12.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_161_18481999.1130166595111" References: <1129931087.19971.12.camel@localhost.localdomain> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.36 required=5 tests=[AWL=-0.169, HTML_20_30=0.504, HTML_MESSAGE=0.001, RCVD_BY_IP=0.024] X-Spam-Level: X-Archive-Number: 200510/332 X-Sequence-Number: 15100 ------=_Part_161_18481999.1130166595111 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just to play devils advocate here for as second, but if we have an algorith= m that is substational better than just plain old LRU, which is what I believ= e the kernel is going to use to cache pages (I'm no kernel hacker), then why don't we apply that and have a significantly larger page cache a la Oracle? Alex On 10/21/05, Neil Conway wrote: > > On Fri, 2005-21-10 at 07:34 -0500, Martin Nickel wrote: > > Let's say I do the same thing in Postgres. I'm likely to have my very > > fastest performance for the first few queries until memory gets filled > up. > > No, you're not: if a query doesn't hit the cache (both the OS cache and > the Postgres userspace cache), it will run slower. If the caches are > empty when Postgres starts up (which is true for the userspace cache and > might be true of the OS cache), the first queries that are run should be > slower, not faster. > > > The only time Postgres seems to take advantage of cached data is when I > > repeat the same (or substantially the same) query. > > Caching is done on a page-by-page basis -- the source text of the query > itself is not relevant. If two different queries happen to hit a similar > set of pages, they will probably both benefit from the same set of > cached pages. > > > I don't know of any way to view what is actually cached at any point > > in time, but it seems like "most recently used" rather than "most > > frequently used". > > The cache replacement policy in 7.4 and older releases is simple LRU. > The policy in 8.0 is ARC (essentially a version of LRU modified to try > to retain hot pages more accurately). The policy in 8.1 is a clock-based > algorithm. > > -Neil > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend > ------=_Part_161_18481999.1130166595111 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Just to play devils advocate here for as second, but if we have an algorithm that is substational better than just plain old LRU, which is what I believe the kernel is going to use to cache pages (I'm no kernel hacker), then why don't we apply that and have a significantly larger page cache a la Oracle?

Alex

On 10/21/05, Neil Conway <neilc= @samurai.com> wrote:
On Fri, 2005-21-10 at 07:34 -0500, Martin Nickel wrote:
> Let's say I= do the same thing in Postgres.  I'm likely to have my very
&g= t; fastest performance for the first few queries until memory gets filled u= p.

No, you're not: if a query doesn't hit the cache (both the OS cache and=
the Postgres userspace cache), it will run slower. If the caches areempty when Postgres starts up (which is true for the userspace cache and
might be true of the OS cache), the first queries that are run should b= e
slower, not faster.

>  The only time Postgres seem= s to take advantage of cached data is when I
>  repeat the = same (or substantially the same) query.

Caching is done on a page-by-page basis -- the source text of the q= uery
itself is not relevant. If two different queries happen to hit a si= milar
set of pages, they will probably both benefit from the same set of
cached pages.

> I don't know of any way to view what is actua= lly cached at any point
> in time, but it seems like "most recen= tly used" rather than "most
> frequently used".

The cache replacement policy in 7.4 and older releases is simple LRU.The policy in 8.0 is ARC (essentially a version of LRU modified to tryto retain hot pages more accurately). The policy in 8.1 is a clock-based
algorithm.

-Neil



---------------------------(end = of broadcast)---------------------------
TIP 6: explain analyze is your = friend

------=_Part_161_18481999.1130166595111--