| From: | Dmitry Dolgov <9erthalion6(at)gmail(dot)com> |
|---|---|
| To: | Andrey Borodin <x4mmm(at)yandex-team(dot)ru> |
| Cc: | Peter Geoghegan <pg(at)bowt(dot)ie>, pgsql-hackers mailing list <pgsql-hackers(at)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de> |
| Subject: | Re: Randomize B-Tree page split location to avoid oscillating patterns |
| Date: | 2026-08-28 20:39:02 |
| Message-ID: | apHxBDeucnJmIlVD@ddolgov-thinkpadt14sgen1.rmtde.csb |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
> On Tue, Aug 25, 2026 at 04:27:25PM +0500, Andrey Borodin wrote:
> > If I got you correct, we still would need to keep locations with the
> > true minimum penalty, so this part sounds similar to what already
> > happens in the v2.
>
> We only need to keep one selected location and the number of equally
> good locations seen so far. In pseudocode:
>
> if (penalty < bestpenalty)
> bestpenalty = penalty, selected = i, nmatches = 1;
> else if (penalty == bestpenalty)
> if (random(++nmatches) == 0)
> selected = i;
>
> After a full scan, this produces the same random choice among locations
> with the true minimum penalty as collecting those locations in an array
> and choosing an element at the end, without storing the array.
I see, but it will also require more calls of random number generation,
and it's not obvious to me that this would have less overhead. Let me
experiment with this part, but otherwise I assume you find the patch
idea sound?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Gustavo William | 2026-08-28 20:43:44 | Re: enhancing pg_basebackup speeds up to ~23Gbps (small fixes + io_uring/Direct I/O) |
| Previous Message | Bharath Rupireddy | 2026-08-28 20:20:00 | Re: REPACK (CONCURRENTLY) backend waits indefinitely when decoding worker fails to start |