I have an idea that makes some assumptions about internals that I think are correct.
When you have a huge number of buffers in a list that has to be traversed to look for things in cache, e.g. 100k, you will generate an almost equivalent number of cache line misses on the processor to jump through all those buffers. As I understand it (and I haven't looked so I could be wrong), the buffer cache is searched by traversing it sequentially. OTOH, it seems reasonable to me that the OS disk cache may actually be using a tree structure that would generate vastly fewer cache misses by comparison to find a buffer. This could mean a substantial linear search cost as a function of the number of buffers, big enough to rise above the noise floor when you have hundreds of thousands of buffers. Cache misses start to really add up when a code path generates many, many thousands of them, and differences in the access path between the buffer cache and disk cache would be reflected when you have that many buffers. I've seen these types of unexpected performance anomalies before that got traced back to code patterns and cache efficiency and gotten integer factors improvements by making some seemingly irrelevant code changes. So I guess my question would be 1) are my assumptions about the internals correct, and 2) if they are, is there a way to optimize searching the buffer cache so that a search doesn't iterate over a really long buffer list that is bottlenecked on cache line replacement. My random thought of the day, j. andrew rogers ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org