Re: Reduce build times of pg_trgm GIN indexes

From: David Geier <geidav(dot)pg(at)gmail(dot)com>
To: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reduce build times of pg_trgm GIN indexes
Date: 2026-03-03 17:31:51
Message-ID: 2a76b5ef-4b12-4023-93a1-eed6e64968f3@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Attached are the patches rebased on latest master.
>
> I've removed the ASCII fast-path patch 0006 as it turned out to be more
> complicated to make work than expected.
>
> I kept the radix sort patch because it gives a decent speedup but I
> would like to focus for now on getting patches 0001 - 0004 merged.
> They're all simple and, the way I see it, uncontroversial.
>
> I remeasured the savings of 0001 - 0004, which comes on top of the
> already committed patch that inlined the comparison function, which gave
> another ~5%:
>
> Data set | Patched (ms) | Master (ms) | Speedup
> --------------------|--------------|--------------|----------
> movies(plot) | 8,058 | 10,311 | 1.27x
> lineitem(l_comment) | 223,233 | 256,986 | 1.19x
>
> I've also registered the change at the commit fest, see
> https://commitfest.postgresql.org/patch/6418/.

Attached is v5 that removes an incorrect assertion from the radix sort code.

--
David Geier

Attachment Content-Type Size
v5-0005-Optimize-generate_trgm-with-radix-sort.patch text/x-patch 2.8 KB
v5-0004-Faster-qunique-comparator-in-generate_trgm.patch text/x-patch 2.0 KB
v5-0003-Make-btint4cmp-branchless.patch text/x-patch 1.0 KB
v5-0002-Optimize-generate_trgm-with-sort_template.h.patch text/x-patch 2.6 KB
v5-0001-Optimize-sort-and-deduplication-in-ginExtractEntr.patch text/x-patch 7.8 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Joel Jacobson 2026-03-03 17:33:31 Re: [BUG?] estimate_hash_bucket_stats uses wrong ndistinct for avgfreq
Previous Message Fujii Masao 2026-03-03 17:29:27 Re: Shutdown indefinitely stuck due to unflushed FPI_FOR_HINT record