Re: Index range search optimization

2023-10-07 Thread Alexander Korotkov
On Fri, Oct 6, 2023 at 9:59 PM Pavel Borisov wrote: > On Fri, 6 Oct 2023 at 22:44, Konstantin Knizhnik wrote: > > > > > > On 04/10/2023 3:00 am, Alexander Korotkov wrote: > > > On Wed, Oct 4, 2023 at 12:59 AM Pavel Borisov > > > wrote: > > >> I've looked through the patch v8. I think it's good

Re: Index range search optimization

2023-10-06 Thread Pavel Borisov
Hi, Konstantin! On Fri, 6 Oct 2023 at 22:44, Konstantin Knizhnik wrote: > > > On 04/10/2023 3:00 am, Alexander Korotkov wrote: > > On Wed, Oct 4, 2023 at 12:59 AM Pavel Borisov > > wrote: > >> I've looked through the patch v8. I think it's good enough to be > >> pushed if Peter has no objection

Re: Index range search optimization

2023-10-06 Thread Konstantin Knizhnik
On 04/10/2023 3:00 am, Alexander Korotkov wrote: On Wed, Oct 4, 2023 at 12:59 AM Pavel Borisov wrote: I've looked through the patch v8. I think it's good enough to be pushed if Peter has no objections. Thank you, Pavel. I'll push this if there are no objections. -- Regards, Alexander Ko

Re: Index range search optimization

2023-10-03 Thread Alexander Korotkov
On Wed, Oct 4, 2023 at 12:59 AM Pavel Borisov wrote: > I've looked through the patch v8. I think it's good enough to be > pushed if Peter has no objections. Thank you, Pavel. I'll push this if there are no objections. -- Regards, Alexander Korotkov

Re: Index range search optimization

2023-10-03 Thread Pavel Borisov
Hi! On Fri, 29 Sept 2023 at 10:35, Alexander Korotkov wrote: > > Hi, Peter. > > On Fri, Sep 29, 2023 at 4:57 AM Peter Geoghegan wrote: > > On Fri, Sep 22, 2023 at 7:24 AM Alexander Korotkov > > wrote: > > > The thing is that NULLs could appear in the middle of matching values. > > > > > > # WI

Re: Index range search optimization

2023-09-28 Thread Alexander Korotkov
Hi, Peter. On Fri, Sep 29, 2023 at 4:57 AM Peter Geoghegan wrote: > On Fri, Sep 22, 2023 at 7:24 AM Alexander Korotkov > wrote: > > The thing is that NULLs could appear in the middle of matching values. > > > > # WITH t (a, b) AS (VALUES ('a', 'b'), ('a', NULL), ('b', 'a')) > > SELECT a, b, (a,

Re: Index range search optimization

2023-09-28 Thread Peter Geoghegan
On Fri, Sep 22, 2023 at 7:24 AM Alexander Korotkov wrote: > The thing is that NULLs could appear in the middle of matching values. > > # WITH t (a, b) AS (VALUES ('a', 'b'), ('a', NULL), ('b', 'a')) > SELECT a, b, (a, b) > ('a', 'a') FROM t ORDER BY (a, b); > a | b | ?column? > ---+--+

Re: Index range search optimization

2023-09-28 Thread Alexander Korotkov
On Thu, Sep 28, 2023 at 5:21 AM Peter Geoghegan wrote: > On Wed, Sep 27, 2023 at 9:41 AM Alexander Korotkov > wrote: > > Fixed typo inficating => indicating as pointed by Pavel. > > Peter, what do you think about the current shape of the patch? > > I'll try to get to this tomorrow. I'm rather bu

Re: Index range search optimization

2023-09-27 Thread Peter Geoghegan
On Wed, Sep 27, 2023 at 9:41 AM Alexander Korotkov wrote: > Fixed typo inficating => indicating as pointed by Pavel. > Peter, what do you think about the current shape of the patch? I'll try to get to this tomorrow. I'm rather busy with moving home at the moment, unfortunately. -- Peter Geoghe

Re: Index range search optimization

2023-09-27 Thread Alexander Korotkov
On Mon, Sep 25, 2023 at 1:18 PM Alexander Korotkov wrote: > On Mon, Sep 25, 2023 at 12:58 PM Pavel Borisov > wrote: > > One more doubt about naming. Calling function > > _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, int tupnatts, > > ScanDirection dir, bool *continuescan, bool requiredMatc

Re: Index range search optimization

2023-09-25 Thread Alexander Korotkov
On Mon, Sep 25, 2023 at 12:58 PM Pavel Borisov wrote: > One more doubt about naming. Calling function > _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, int tupnatts, > ScanDirection dir, bool *continuescan, bool requiredMatchedByPrecheck) > as > (void) _bt_checkkeys(scan, itup, indnatts, dir,

Re: Index range search optimization

2023-09-25 Thread Pavel Borisov
Sorry, I've mistaken with attached version previously. Correct v5 attached. On Mon, 25 Sept 2023 at 13:58, Pavel Borisov wrote: > > Hi, Alexander! > > I found and fixed a couple of naming issues that came to v4 from > earlier patches. > Also, I added initialization of requiredMatchedByPrecheck in

Re: Index range search optimization

2023-09-25 Thread Pavel Borisov
Hi, Alexander! I found and fixed a couple of naming issues that came to v4 from earlier patches. Also, I added initialization of requiredMatchedByPrecheck in case of first page. Please see patch v5. One more doubt about naming. Calling function _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple,

Re: Index range search optimization

2023-09-22 Thread Alexander Korotkov
Hi Peter, Hi Pavel, The v4 of the patch is attached. On Thu, Sep 21, 2023 at 11:48 PM Peter Geoghegan wrote: > > On Thu, Sep 21, 2023 at 5:11 AM Pavel Borisov wrote: > > I looked at the patch code and I agree with this optimization. > > Implementation also looks good to me except change : > > +

Re: Index range search optimization

2023-09-22 Thread Pavel Borisov
On Fri, 22 Sept 2023 at 00:48, Peter Geoghegan wrote: > > On Thu, Sep 21, 2023 at 5:11 AM Pavel Borisov wrote: > > I looked at the patch code and I agree with this optimization. > > Implementation also looks good to me except change : > > + if (key->sk_flags & (SK_BT_REQFWD | SK_BT_REQBKWD) && >

Re: Index range search optimization

2023-09-21 Thread Peter Geoghegan
On Thu, Sep 21, 2023 at 5:11 AM Pavel Borisov wrote: > I looked at the patch code and I agree with this optimization. > Implementation also looks good to me except change : > + if (key->sk_flags & (SK_BT_REQFWD | SK_BT_REQBKWD) && > + !(key->sk_flags & SK_ROW_HEADER)) > + requiredDir = true; > ...

Re: Index range search optimization

2023-09-21 Thread Pavel Borisov
On Thu, 21 Sept 2023 at 15:17, Alexander Korotkov wrote: > > On Wed, Sep 20, 2023 at 5:07 PM Alexander Korotkov > wrote: > > On Tue, Sep 19, 2023 at 1:48 AM Peter Geoghegan wrote: > > This also makes sense. I've rephrased the comment. > > The revised patch is attached. It contains better comm

Re: Index range search optimization

2023-09-21 Thread Alexander Korotkov
On Wed, Sep 20, 2023 at 5:07 PM Alexander Korotkov wrote: > On Tue, Sep 19, 2023 at 1:48 AM Peter Geoghegan wrote: > This also makes sense. I've rephrased the comment. The revised patch is attached. It contains better comments and the commit message. Peter, could you please check if you're OK

Re: Index range search optimization

2023-09-20 Thread Alexander Korotkov
Hi, Peter! Thank you for your interest in this patch. On Tue, Sep 19, 2023 at 1:48 AM Peter Geoghegan wrote: > > On Thu, Sep 14, 2023 at 3:23 AM Alexander Korotkov > wrote: > > The attached patch allows Postgres to skip scan keys required for > > directional scans (even when other keys are pr

Re: Index range search optimization

2023-09-18 Thread Peter Geoghegan
On Thu, Sep 14, 2023 at 3:23 AM Alexander Korotkov wrote: > The attached patch allows Postgres to skip scan keys required for directional > scans (even when other keys are present in the scan). I'll soon post the > testing results and a more polished version of this patch. This is very interes

Re: Index range search optimization

2023-09-14 Thread Alexander Korotkov
Hi! On Fri, Jun 23, 2023 at 10:36 AM Konstantin Knizhnik wrote: > _bt_readpage performs key check for each item on the page trying to locate > upper boundary. > While comparison of simple integer keys are very fast, comparison of long > strings can be quite expensive. > We can first make check f

Index range search optimization

2023-06-23 Thread Konstantin Knizhnik
Hi hackers. _bt_readpage performs key check for each item on the page trying to locate upper boundary. While comparison of simple integer keys are very fast, comparison of long strings can be quite expensive. We can first make check for the largest key on the page and if it is not larger than