Re: index prefetching

From: Tomas Vondra <tomas(at)vondra(dot)me>
To: Andres Freund <andres(at)anarazel(dot)de>, Peter Geoghegan <pg(at)bowt(dot)ie>
Cc: Konstantin Knizhnik <knizhnik(at)garret(dot)ru>, 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>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>
Subject: Re: index prefetching
Date: 2025-12-17 19:54:04
Message-ID: 6a736ea5-62f8-48fd-bd2d-e038f8a294a0@vondra.me
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/17/25 20:30, Andres Freund wrote:
> Hi,
>
> On 2025-12-17 13:49:43 -0500, Peter Geoghegan wrote:
>> On Wed, Dec 17, 2025 at 12:19 PM Konstantin Knizhnik <knizhnik(at)garret(dot)ru> wrote:
>>> Moreover with `enable_indexscan_prefetch=off` results are the same.
>>
>> It's quite unlikely that the current heuristics that trigger
>> prefetching would have ever allowed any prefetching, for queries such
>> as these.
>>
>> The exact rule right now is that we don't even begin prefetching until
>> we've already read at least one index leaf page, and have to read
>> another one. So it's impossible to use prefetching with a LIMIT of 1,
>> with queries such as these. It's highly unlikely that you'd see any
>> benefits from prefetching even with LIMIT 100 (usually we wouldn't
>> even begin prefetching).
>
> Note that due to the tuple size and fillfactor in Konstantin's workload, there
> will be one tuple per page... That should allow for some prefetching.
>

Yes, but that's in the heap. The mechanism Peter described is about leaf
pages in the index, and the index has the usual fillfactor. So there'll
be many index entries per leaf.

regards

--
Tomas Vondra

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Matheus Alcantara 2025-12-17 20:01:31 Re: Asynchronous MergeAppend
Previous Message Peter Geoghegan 2025-12-17 19:53:48 Re: index prefetching