Re: Parallel CREATE INDEX for GIN indexes
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Tomas Vondra <tomas@vondra.me>,
Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: Kirill Reshke <reshkekirill@gmail.com>,
Michael Paquier <michael@paquier.xyz>,
PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2026-01-11T20:31:07Z
Lists: pgsql-hackers
(Replying to old thread, because I happened to spot this while looking
at David Geier's proposal at:
https://www.postgresql.org/message-id/5d366878-2007-4d31-861e-19294b7a583b%40gmail.com)
On 07/01/2025 13:59, Tomas Vondra wrote:
> On 1/6/25 20:13, Matthias van de Meent wrote:
>>> GinBufferInit
>>
>> This seems to depend on the btree operator classes to get sortsupport
>> functions, bypassing the GIN compare support function (support
>> function 1) and adding a dependency on the btree opclasses for
>> indexable types. This can cause "bad" ordering, or failure to build
>> the index when the parallel path is chosen and no default btree
>> opclass is defined for the type. I think it'd be better if we allowed
>> users to specify which sortsupport function to use, or at least use
>> the correct compare function when it's defined on the attribute's
>> operator class.
>
> Good point! I fixed this by copying the logic from initGinState.
I think tuplesort_begin_index_gin() has the same issue. It does this to
look up the comparison function:
/*
* Look for an ordering for the index key data type, and then the sort
* support function.
*/
typentry = lookup_type_cache(att->atttypid, TYPECACHE_LT_OPR);
PrepareSortSupportFromOrderingOp(typentry->lt_opr, sortKey);
That also looks up the key type's b-tree operator rather than the GIN
opclass's compare function.
- Heikki
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Exercise parallel GIN builds in regression tests
- f6e5d21bf73f 19 (unreleased) landed
- 32593394ee43 18.2 landed
-
Lookup the correct ordering for parallel GIN builds
- db14dcdec69d 19 (unreleased) landed
- eee71a66cc86 18.2 landed
-
Fix memory leak in _gin_parallel_merge
- 1681a70df3d6 18.0 landed
-
Enforce memory limit during parallel GIN builds
- b229c1016477 18.0 landed
-
Compress TID lists when writing GIN tuples to disk
- 0b2a45a5d1f2 18.0 landed
-
Allow parallel CREATE INDEX for GIN indexes
- 8492feb98f6d 18.0 landed