postgresql/src
Tomas Vondra 8492feb98f Allow parallel CREATE INDEX for GIN indexes
Allow using parallel workers to build a GIN index, similarly to BTREE
and BRIN. For large tables this may result in significant speedup when
the build is CPU-bound.

The work is divided so that each worker builds index entries on a subset
of the table, determined by the regular parallel scan used to read the
data. Each worker uses a local tuplesort to sort and merge the entries
for the same key. The TID lists do not overlap (for a given key), which
means the merge sort simply concatenates the two lists. The merged
entries are written into a shared tuplesort for the leader.

The leader needs to merge the sorted entries again, before writing them
into the index. But this way a significant part of the work happens in
the workers, and the leader is left with merging fewer large entries,
which is more efficient.

Most of the parallelism infrastructure is a simplified copy of the code
used by BTREE indexes, omitting the parts irrelevant for GIN indexes
(e.g. uniqueness checks).

Original patch by me, with reviews and substantial improvements by
Matthias van de Meent, certainly enough to make him a co-author.

Author: Tomas Vondra, Matthias van de Meent
Reviewed-by: Matthias van de Meent, Andy Fan, Kirill Reshke
Discussion: https://postgr.es/m/6ab4003f-a8b8-4d75-a67f-f25ad98582dc%40enterprisedb.com
2025-03-03 16:53:06 +01:00
..
backend Allow parallel CREATE INDEX for GIN indexes 2025-03-03 16:53:06 +01:00
bin Use PRI*64 instead of "ll*" in format strings (minimal trial) 2025-03-02 13:53:03 +01:00
common Change relpath() et al to return path by value 2025-02-25 09:02:07 -05:00
fe_utils Get rid of O(N^2) script-parsing overhead in pgbench. 2025-02-27 10:53:38 -05:00
include Allow parallel CREATE INDEX for GIN indexes 2025-03-03 16:53:06 +01:00
interfaces Work around OAuth/EVFILT_TIMER quirk on NetBSD. 2025-03-01 14:41:02 +13:00
makefiles Add support for OAUTHBEARER SASL mechanism 2025-02-20 16:25:17 +01:00
pl Revert "Prepare for Python "Limited API" in PL/Python" 2025-02-26 21:58:38 +01:00
port Fix pg_strtof() to not crash on NULL endptr. 2025-03-01 14:22:56 -05:00
template thread-safety: gmtime_r(), localtime_r() 2024-08-23 07:43:04 +02:00
test Tweak regex to avoid a bug in Perl 5.16.3. 2025-02-28 15:20:24 -05:00
timezone Update time zone data files to tzdata release 2025a. 2025-01-20 16:49:15 -05:00
tools Allow parallel CREATE INDEX for GIN indexes 2025-03-03 16:53:06 +01:00
tutorial Doc: simplify the tutorial's window-function examples. 2025-01-21 14:43:21 -05:00
.gitignore
DEVELOPERS
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
Makefile.global.in Add support for OAUTHBEARER SASL mechanism 2025-02-20 16:25:17 +01:00
Makefile.shlib Remove AIX support 2024-02-28 15:17:23 +04:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
nls-global.mk Remove distprep 2023-11-06 15:18:04 +01:00