Re: index prefetching

From: Alexandre Felipe <o(dot)alexandre(dot)felipe(at)gmail(dot)com>
To: Tomas Vondra <tomas(at)vondra(dot)me>
Cc: Peter Geoghegan <pg(at)bowt(dot)ie>, Andres Freund <andres(at)anarazel(dot)de>, Thomas Munro <thomas(dot)munro(at)gmail(dot)com>, Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Melanie Plageman <melanieplageman(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Georgios <gkokolatos(at)protonmail(dot)com>, Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: index prefetching
Date: 2026-03-12 18:32:23
Message-ID: CAE8JnxOygarzQpBbBHV+_QZ2A=K01de_iFcn08+D6hNGS3kHPg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

1) v12-0001-Use-simple-hash-for-PrivateRefCount.patch
>
> - seems like a (mostly) mechanical switch for a different hashtable

But Andres slapped me with a question: "Did you try on a real query?"
When I tried on a real query it was a bit slower on the that Andres gave as
an
example:
SELECT sum(balance) INTO s FROM uncorrelated WHERE id > 1000 and id <
500000;

It is marginal but consistently slower, I guess it is just the presence of
more code
patched: 120.36 - 124.98
master: 116.19 - 118.09
Passing -falign-functionns=64
patched: 117.82 - 118.88
master: 115.40 - 119.91

Maybe just the presence of more the code, because we don't touch the hash.
I tried with SH_SCOPE `static` or `static pg_noinline` but that doesn't
help either.
Assuming one ReadBuffer/ReleaseBuffer per row, we can infer infer that it
was
~3ms / 5e5 = 6ns slower.

On micro benchmarking it cuts the gap by half when holding 100 to 1000
buffers.

[image: image.png]

If we can accept one more pointer dereference, by having a pointer instead
of a static
array we can reduce by the ramp by 80% (and no, that is not achieved by
placing
the bottom of the ramp half way up hehe)

Regards,
Alexandre

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2026-03-12 18:41:03 Re: Better shared data structure management and resizable shared data structures
Previous Message Alvaro Herrera 2026-03-12 18:25:54 Re: Adding REPACK [concurrently]