On Fri, 6 Jul 2007, Tom Lane wrote:

The problem is that it'd be very hard to track how far ahead of the recycling sweep hand we are, because that number has to be measured in usage-count-zero pages. I see no good way to know how many of the pages we scanned before have been touched (and given nonzero usage counts) unless we rescan them.

## Advertising

`I've actually been working on how to address that specific problem without`

`expressly tracking the contents of the buffer cache. When the background`

`writer is called, it finds out how many buffers were allocated and how far`

`the sweep point moved since the last call. From that, you can calculate`

`how many buffers on average need to be scanned per allocation, which tells`

`you something about the recently encountered density of 0-usage count`

`buffers. My thought was to use that as an input to the computation for`

`how far ahead to stay.`

I've been doing moving averages for years and years, and I find that the multiplication approach works at least as well as explicitly storing the last K observations. It takes a lot less storage and arithmetic too.

`I was simplifying the description just to comment on the range for K; I`

`was using a multiplication approach for the computation.`

-- * Greg Smith [EMAIL PROTECTED] http://www.gregsmith.com Baltimore, MD ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend