Re: [PATCH] Add sortsupport for range types and btree_gist

x4mmm@yandex-team.ru

From: "Andrey M. Borodin" <x4mmm@yandex-team.ru>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bernd Helmle <mailings@oopsware.de>, jian he <jian.universality@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-11-29T09:41:56Z
Lists: pgsql-hackers
Thanks for your valuable input, Michael!

> On 29 Nov 2024, at 09:42, Michael Paquier <michael@paquier.xyz> wrote:
> 
> As a whole, I'm very dubious about the need for injection points at
> all here.  The sortsupport property claimed for this patch tells that
> this results in smaller index sizes, but the tests don't really check
> that: they just make sure that sortsupport routine paths are taken.
> What this should test is not the path taken, but how the new code
> affects the index data generated.

Actually, that’s exactly what we wanted to test: which paths are taken.
Resulting index might be of a very same size in case of B-tree-over-GiST. Resulting index is drastically smaller for geometry, e.g. PostGIS. But event that’s not main effect: the index is simply build much faster (on par with actual B-tree).
We need this sort support for btree_gist to be able to use non-geometry datatypes in combination with geometry.
e.g.
CREATE INDEX ON table USING gist(project_id_of_type_int,geometric_column);
Currently, having anything non-geometric in GiST slows down it 10x, because sorting build path is not taken.
In PG15 we put extra effort to make resulting indexes indistinguishable from normally-built. Primarily for the sake of IndexScan performance.


Best regards, Andrey Borodin.





Commits

  1. Add support for sorted gist index builds to btree_gist

  2. Add GiST and btree sortsupport routines for range types

  3. Change gist stratnum function to use CompareType

  4. Doc: improve documentation for jsonpath behavior.

  5. Add sortsupport for gist_btree opclasses, for faster index builds.