Kevin Grittner wrote: > Tom Lane <t...@sss.pgh.pa.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%.
Two things that might not have been mentioned: First, only reset if you are given a page in the last 1/4 of the table; that way, if there is no free space in the last 1/4 of the table, you will not be resetting. A second idea is to heavily bias against using the last table page with data in it; that should help bias toward empty pages on the end of the table. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + If your life is a hard drive, Christ can be your backup. + -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers