Re: Reduce build times of pg_trgm GIN indexes

David Geier <geidav.pg@gmail.com>

From: David Geier <geidav.pg@gmail.com>
To: Heikki Linnakangas <hlinnaka@iki.fi>, Matthias van de Meent <boekewurm+postgres@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-04-13T15:06:40Z
Lists: pgsql-hackers
Hi Heikki!

> Pushed 0001 as commit 6f5ad00ab7.
> 
> I squashed 0002 and 0004 into one commit, and did some more refactoring:
> I created a trigram_qsort() helper function that calls the signed or
> unsigned variant, so that that logic doesn't need to be duplicated in
> the callers. For symmetry, I also added a trigram_qunique() helper
> function which just calls qunique() with the new, faster CMPTRGM_EQ
> comparator. Pushed these as commit 9f3755ea07.

Thanks for committing these patches.

--
David Geier



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Change PointerGetDatum() back to a macro

  2. Replace deprecated StaticAssertStmt() with StaticAssertDecl()

  3. Optimize sorting and deduplicating trigrams

  4. Optimize sort and deduplication in ginExtractEntries()

  5. Inline ginCompareAttEntries for speed