Re: Caching (was Re: choosing the right platform) - Mailing list pgsql-performance

From Jean-Luc Lachance
Subject Re: Caching (was Re: choosing the right platform)
Date
Msg-id 3E957F44.A1106F6A@nsd.ca
Whole thread Raw
In response to Re: choosing the right platform  ("Matthew Nuzum" <cobalt@bearfruit.org>)
Responses Re: Caching (was Re: choosing the right platform)
List pgsql-performance
Tom,

What appends when PG scans a table that is is too big to fit in the
cache?
Won't the whole cache get trashed and swapped off to disk?
Shouldn't there be a way to lock some tables in PG cache?
Who about caracterizing some of the RAM like: scan, index, small
frequently used tables.

JLL

Tom Lane wrote:
> [...]
> PG is *not* any smarter about the usage patterns of its disk buffers
> than the kernel is; it uses a simple LRU algorithm that is surely no
> brighter than what the kernel uses.  (We have looked at smarter buffer
> recycling rules, but failed to see any performance improvement.)  So the
> notion that PG can do a better job of cache management than the kernel
> is really illusory.  About the only advantage you gain from having data
> directly in PG buffers rather than kernel buffers is saving the CPU
> effort needed to move data across the userspace boundary --- which is
> not zero, but it's sure a lot less than the time spent for actual I/O.
>
> So my take on it is that you want shared_buffers fairly small, and let
> the kernel do the bulk of the heavy lifting for disk cache.  That's what
> it does for a living, so let it do what it does best.  You only want
> shared_buffers big enough so you don't spend too many CPU cycles shoving
> data back and forth between PG buffers and kernel disk cache.  The
> default shared_buffers setting of 64 is surely too small :-(, but my
> feeling is that values in the low thousands are enough to get past the
> knee of that curve in most cases.


pgsql-performance by date:

Previous
From: Shridhar Daithankar
Date:
Subject: Re: Caching (was Re: choosing the right platform)
Next
From: Tom Lane
Date:
Subject: Re: Caching (was Re: choosing the right platform)