Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> (Hm, so we might want to make the probability depend on
> max_connections?)
Without doing rigorous math on it, I'd guess that to prevent
contention among n connections you'd want the probably of resetting
the sweep to be about 1 / (n * 2). That would mean you'd advance to
the nth page about 60.6% of the time without resetting the sweep. For
less contention, 1 / (n * 4) would let you get to the nth page about
77.9% of the time.
> Maybe what we want is some bias against inserting in the last half
> or quarter of the table, or some such rule, rather than necessarily
> heading for the start of the relation.
I think it would make sense to just start using this once you get into
the last half or quarter of the free pages. If you go with the last
quarter, then you might want to use a higher probability than I
suggested above, although that would tend to leave you with contention
when all the free space was in the last quarter. I'd be inclined to
use something like the above probability and start using it at 50%.
-Kevin