From: | Simon Riggs <simon(at)2ndQuadrant(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: our buffer replacement strategy is kind of lame |
Date: | 2011-08-12 08:33:07 |
Message-ID: | CA+U5nM+ehRp=qf37EFJ0WYxoODYvzAZunfrg=s0=jaQhqxHARg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, Aug 12, 2011 at 5:05 AM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
> rhaas=# select usagecount, sum(1) from pg_buffercache group by 1 order by 1;
> usagecount | sum
> ------------+-------
> 1 | 136
> 2 | 12
> 3 | 72
> 4 | 7
> 5 | 13755
> | 37218
> (6 rows)
>
> Only 96 of the 14286 buffers in sample_data are in shared_buffers,
> despite the fact that we have 37,218 *completely unused* buffers lying
> around. That sucks, because it means that the sample query did a
> whole lot of buffer eviction that was completely needless. The ring
> buffer is there to prevent trashing the shared buffer arena, but here
> it would have been fine to trash the arena: there wasn't anything
> there we would have minded losing (or, indeed, anything at all).
You're missing an important point. The SeqScan is measurably faster
when using the ring buffer because of the effects of L2 cacheing on
the buffers.
Also, your logic is a little off, since you're doing the scan on an
otherwise quiet machine soon after startup and there are some
completely unused buffers. That isn't the typical state of the buffer
cache and so spoiling the cache is not acceptable in the general case.
The above case doesn't suck because it carefully reserved parts of
shared buffers for other users when spoiling the cache would be of no
benefit to the user, so it worked great from my perspective.
--
Simon Riggs http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Simon Riggs | 2011-08-12 08:36:32 | Re: our buffer replacement strategy is kind of lame |
Previous Message | Heikki Linnakangas | 2011-08-12 08:23:55 | Re: WIP: Fast GiST index build |