Re: Optimize single tuple fetch from nbtree index - Mailing list pgsql-hackers

From Floris Van Nee
Subject Re: Optimize single tuple fetch from nbtree index
Date
Msg-id 1566850957044.90770@Optiver.com
Whole thread Raw
In response to Re: Optimize single tuple fetch from nbtree index  (Anastasia Lubennikova <a.lubennikova@postgrespro.ru>)
Responses Re: Optimize single tuple fetch from nbtree index  (Floris Van Nee <florisvannee@Optiver.com>)
List pgsql-hackers
> It seems that it contradicts the very idea of your patch, so probably we
> should look for other ways to optimize this use-case.
> Maybe this restriction can be relaxed for write only tables, that never
> have to reread the page because of visibility, or something like that.
> Also we probably can add to IndexScanDescData info about expected number
> of tuples, to allow index work more optimal
> and avoid the overhead for other loads.=

The idea of the patch is exactly to relax this limitation. I forgot to update that README file though. The current
implementationof the patch should be correct like this - that's why I added the look-back code on the page if the tuple
couldn'tbe found anymore on the same location on the page. Similarly, it'll look on the page to the right if it
detecteda page split. These two measures combined should give a correct implementation of the 'it's possible that a
scanstops in the middle of a page' relaxation. However, as Peter and Tom pointed out earlier, they feel that the
performanceadvantage that this approach gives, does not outweigh the extra complexity at this time. I'd be open to
othersuggestions though. 

> That's true. It took me quite some time to understand that existing code
> is correct.
> There is a comment for the structure's field that claims that
> BufferIsValid is the same that BufferIsPinned in ScanPos context.
> Attached patch contains some comments' updates. Any suggestions on how
> to improve them are welcome.

I'll have a look tomorrow. Thanks a lot for writing this up!

-Floris



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: assertion at postmaster start
Next
From: Tomas Vondra
Date:
Subject: Re: subscriptionCheck failures on nightjar