Re: index prefetching - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: index prefetching
Date
Msg-id 6a736ea5-62f8-48fd-bd2d-e038f8a294a0@vondra.me
Whole thread Raw
In response to Re: index prefetching  (Andres Freund <andres@anarazel.de>)
Responses Re: index prefetching
List 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@garret.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




pgsql-hackers by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: index prefetching
Next
From: "Matheus Alcantara"
Date:
Subject: Re: Asynchronous MergeAppend