pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Anton A. Melnikov <a.melnikov@postgrespro.ru>
To: Peter Geoghegan <pg@bowt.ie>
To: Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Tomas Vondra <tomas.vondra@enterprisedb.com>
Cc: Jeff Davis <pgsql@j-davis.com>
Cc: benoit <benoit@hopsandfork.com>
Cc: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Heikki Linnakangas <hlinnaka@iki.fi>
Subject: Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan
Date: Wed, 31 Jul 2024 07:47:33 +0300
Message-ID: <67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru> (raw)
In-Reply-To: <CAH2-Wzk0B0Ccso31cr1Eo8mfEE5jaggez6kD6WfmPhOQzhkSPA@mail.gmail.com>
References: <CAH2-Wz=ksvN_sjcnD1+Bt-WtifRA5ok48aDYnq3pkKhxgMQpcw@mail.gmail.com>
	<CAH2-WzmjKdovfd-T+o0VaboZCdKnccXSvN4cub3qZw=baC_hyA@mail.gmail.com>
	<CAEze2Whps99tdDfDC4hrL92W1oiZBnFXqv1OB55OMdPXtx6yuA@mail.gmail.com>
	<CAH2-WzmHWR=gqeuq4rHDTv4zHyXDXNTSNxYQKYru4vyaUk=FTQ@mail.gmail.com>
	<CAEze2Wj-EBt8ECp7QScx5bBw4VNg=9T==o=Yh=gUR4__C3h=uA@mail.gmail.com>
	<CAH2-Wz=Ct9fLcN-2SV0gx_iBk87RsAi+Sor3OwR2_5Rg_KO0+g@mail.gmail.com>
	<CAEze2WiR5eJgVqDHCEaO0=mDiUyXY_o-8aK-PTKVPCKba_E4Vg@mail.gmail.com>
	<CAH2-WzmTHoCsOmSgLg=yyft9LoERtuCKXyG2GZn+28PzonFA_g@mail.gmail.com>
	<CAH2-WzkXJnHOuaonxm4xGPXU4n8D6VS2kzdmSy929nmiYYXBeA@mail.gmail.com>
	<CAH2-Wzma8RpVe4XMWxFy5sOUxn4Mxd=jOjwTTzwEB+JNk=vRNg@mail.gmail.com>
	<CAEze2WgRqVrB7G2-oT5iFzyv3u2aiOQD4GjJBiQZ7BrcC6hXJQ@mail.gmail.com>
	<CAH2-WzkrKXZa4wHxJ4rrggWOn8g-Kdu75WGegRJEPxS68PK-hA@mail.gmail.com>
	<CAEze2WhVTv8KsNSmxcJxAV5pLsWsHhdafhor_viQh_O+wq3T2A@mail.gmail.com>
	<CAH2-Wzk0B0Ccso31cr1Eo8mfEE5jaggez6kD6WfmPhOQzhkSPA@mail.gmail.com>

Hi, Peter!

On 20.01.2024 01:41, Peter Geoghegan wrote:
> It is quite likely that there are exactly zero affected out-of-core
> index AMs. I don't count pgroonga as a counterexample (I don't think
> that it actually fullfills the definition of a ). Basically,
> "amcanorder" index AMs more or less promise to be compatible with
> nbtree, down to having the same strategy numbers. So the idea that I'm
> going to upset amsearcharray+amcanorder index AM authors is a
> completely theoretical problem. The planner code evolved with nbtree,
> hand-in-glove.


 From the 5bf748b86bc commit message:

> There is a theoretical risk that removing restrictions on SAOP index
> paths from the planner will break compatibility with amcanorder-based
> index AMs maintained as extensions.  Such an index AM could have the
> same limitations around ordered SAOP scans as nbtree had up until now.
> Adding a pro forma incompatibility item about the issue to the Postgres
> 17 release notes seems like a good idea.

Seems, this commit broke our posted knn_btree patch. [1]
If the point from which ORDER BY goes by distance is greater than the elements of ScalarArrayOp,
then knn_btree algorithm will give only the first tuple. It sorts the elements of ScalarArrayOp
in descending order and starts searching from smaller to larger
and always expects that for each element of ScalarArrayOp there will be a separate scan.
And now it does not work. Reproduction is described in [2].

Seems it is impossible to solve this problem only from the knn-btree patch side.
Could you advise any ways how to deal with this. Would be very grateful.

With the best wishes,

-- 
Anton A. Melnikov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

[1]
https://commitfest.postgresql.org/48/4871/
[2]
https://www.postgresql.org/message-id/47adb0b0-6e65-4b40-8d93-20dcecc21395%40postgrespro.ru





view thread (78+ messages)  latest in thread

Message-ID: <67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru>
Permalink:  ../67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru/
Also on:    postgresql.org/message-id/67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: a.melnikov@postgrespro.ru, pg@bowt.ie, boekewurm+postgres@gmail.com, tgl@sss.pgh.pa.us, tomas.vondra@enterprisedb.com, pgsql@j-davis.com, benoit@hopsandfork.com, aekorotkov@gmail.com, hlinnaka@iki.fi
  Subject: Re: Optimizing nbtree ScalarArrayOp execution, allowing multi-column ordered scans, skip scan
  In-Reply-To: <67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru>
  References: <CAH2-Wz=ksvN_sjcnD1+Bt-WtifRA5ok48aDYnq3pkKhxgMQpcw@mail.gmail.com> <CAEze2Whps99tdDfDC4hrL92W1oiZBnFXqv1OB55OMdPXtx6yuA@mail.gmail.com> <CAH2-WzmHWR=gqeuq4rHDTv4zHyXDXNTSNxYQKYru4vyaUk=FTQ@mail.gmail.com> <CAEze2Wj-EBt8ECp7QScx5bBw4VNg=9T==o=Yh=gUR4__C3h=uA@mail.gmail.com> <CAH2-Wz=Ct9fLcN-2SV0gx_iBk87RsAi+Sor3OwR2_5Rg_KO0+g@mail.gmail.com> <CAEze2WiR5eJgVqDHCEaO0=mDiUyXY_o-8aK-PTKVPCKba_E4Vg@mail.gmail.com> <CAH2-WzmTHoCsOmSgLg=yyft9LoERtuCKXyG2GZn+28PzonFA_g@mail.gmail.com> <CAH2-WzkXJnHOuaonxm4xGPXU4n8D6VS2kzdmSy929nmiYYXBeA@mail.gmail.com> <CAH2-Wzma8RpVe4XMWxFy5sOUxn4Mxd=jOjwTTzwEB+JNk=vRNg@mail.gmail.com> <CAEze2WgRqVrB7G2-oT5iFzyv3u2aiOQD4GjJBiQZ7BrcC6hXJQ@mail.gmail.com> <CAH2-WzkrKXZa4wHxJ4rrggWOn8g-Kdu75WGegRJEPxS68PK-hA@mail.gmail.com> <CAEze2WhVTv8KsNSmxcJxAV5pLsWsHhdafhor_viQh_O+wq3T2A@mail.gmail.com> <CAH2-Wzk0B0Ccso31cr1Eo8mfEE5jaggez6kD6WfmPhOQzhkSPA@mail.gmail.com> <67c2ce53-022c-44e3-9e73-67d62355da01@postgrespro.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox