<div dir="ltr">Hi everyone,<div><br></div><div>After several weeks of research, testing and experiments we believe we found a solution that does not cause the select performance degradation (or sometimes brings profit) and still builds the index faster using the sorting build method. </div><div><br>The patch is posted on pgsql-hackers by Aliaskandr Kalenik in this thread:<br><br><a href="https://www.postgresql.org/message-id/CAHqSB9jqtS94e9%3D0vxqQX5dxQA89N95UKyz-%3DA7Y%2B_YJt%2BVW5A%40mail.gmail.com">https://www.postgresql.org/message-id/CAHqSB9jqtS94e9%3D0vxqQX5dxQA89N95UKyz-%3DA7Y%2B_YJt%2BVW5A%40mail.gmail.com</a><br><br>Patch on commitfest:<br><br><a href="https://commitfest.postgresql.org/36/3487/">https://commitfest.postgresql.org/36/3487/</a><br><br><span style="">Sergei Shoulbakov implemented the benchmark to prove the effect. Results and notes are posted here:</span><br style=""><span style=""><a href="https://www.postgresql.org/message-id/3aa6ba30-e9d8-10ef-753f-8deea5f196d0%40kontur.io">https://www.postgresql.org/message-id/3aa6ba30-e9d8-10ef-753f-8deea5f196d0%40kontur.io</a></span><br><br>We need your help to get it reviewed and merged to get the benefits for everyone in PG15. <br></div><div><br>Darafei. <br><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 3, 2021 at 10:19 PM Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca">pramsey@cleverelephant.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This is done at<br>
<a href="https://github.com/postgis/postgis/commit/d8976c0d2f6b8906b583f24e98fba2ef92fb1277" rel="noreferrer" target="_blank">https://github.com/postgis/postgis/commit/d8976c0d2f6b8906b583f24e98fba2ef92fb1277</a><br>
<br>
On Fri, Dec 3, 2021 at 10:37 AM Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca" target="_blank">pramsey@cleverelephant.ca</a>> wrote:<br>
><br>
> Nevermind, I found the secret incantation:<br>
><br>
> alter operator family gist_geometry_ops_2d using gist drop function 11 (geometry);<br>
><br>
> alter operator family gist_geometry_ops_2d using gist add function 11 (geometry) geometry_gist_sortsupport_2d (internal);<br>
><br>
> P.<br>
><br>
> > On Dec 2, 2021, at 12:57 PM, Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca" target="_blank">pramsey@cleverelephant.ca</a>> wrote:<br>
> ><br>
> > Ding ding!<br>
> > I can strip the sort support function out of the default opclass, but<br>
> > we don't have any way to add it back in, except with a direct<br>
> > alteration of the system tables. If we're OK with that, I will figure<br>
> > out the magic SQL incantation so we can document it, and strip the<br>
> > sort support function from the opclass.<br>
> ><br>
> > P<br>
> ><br>
> > On Wed, Dec 1, 2021 at 1:10 PM Paul Ramsey <<a href="mailto:pramsey@cleverelephant.ca" target="_blank">pramsey@cleverelephant.ca</a>> wrote:<br>
> >><br>
> >> So about this plan, I don't see the ALTER OPERATOR CLASS recipe that can do the thing we want.<br>
> >><br>
> >> <a href="https://www.postgresql.org/docs/14/sql-alteropclass.html" rel="noreferrer" target="_blank">https://www.postgresql.org/docs/14/sql-alteropclass.html</a><br>
> >><br>
> >> What's the magic incantation?<br>
> >><br>
> >>> On Dec 1, 2021, at 8:30 AM, Regina Obe <<a href="mailto:lr@pcorp.us" target="_blank">lr@pcorp.us</a>> wrote:<br>
> >>><br>
> >>>> Initially there was a patch in patchset making user specify sorting function<br>
> >>>> during CREATE INDEX ON table USING gist(column) WITH<br>
> >>>> (sortfunction=zcurve). But everyone said that it's unnessecary complication and<br>
> >>>> we just made the function part of the opclass.<br>
> >>>> But sorting build was not meant to be default!<br>
> >>>><br>
> >>>> I'm going to work on this in December, so let's figure out what exactly do we<br>
> >>>> want from PostgreSQL 15?<br>
> >>>><br>
> >>>> I'm planning to work on:<br>
> >>>> 1. Fix the concurrency problem in IndexOnlyScan that Peter G. pointed out [0]<br>
> >>>> This will further slow down GiST queries a little, sorry.<br>
> >>>> 2. Sorting items within leaf page in tid order, not provided sorting function.<br>
> >>>> 3. Make better splits of leaf pages. Currently we choose how to split leaf pages<br>
> >>>> solely by sorting function. I want to use split function too. This will consume<br>
> >>>> slightly more memory, but will build better index.<br>
> >>>><br>
> >>>> Do we need some functionality to easily enable\disable sorting build? I think<br>
> >>>> chances are very high that we can make it better. But it still will be neither<br>
> >>>> perfect, nor better than buffered build.<br>
> >>>><br>
> >>>> Thanks!<br>
> >>>><br>
> >>>> Best regards, Andrey Borodin.<br>
> >>> [Regina Obe]<br>
> >>> I don't think I was in this discussion about CREATE INDEX ON table USING gist(column) WITH<br>
> >>>> (sortfunction=zcurve).<br>
> >>><br>
> >>> What was the unnecessary complication? Was it deemed "user-facing" too complicated<br>
> >>> or "under the hood" too complicated.<br>
> >>><br>
> >>> For user-facing I don't see it as too complicated. Granted it is a bit extra.<br>
> >>> But if it is deemed always not the absolute best, I feel a configure option is fine.<br>
> >>> It's only giving users redundant equally good options that I would consider too complicated.<br>
> >>><br>
> >>><br>
> >>> _______________________________________________<br>
> >>> postgis-devel mailing list<br>
> >>> <a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
> >>> <a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
> >><br>
><br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">postgis-devel@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-devel" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-devel</a><br>
</blockquote></div>