postgresql/src/include/access
Tomas Vondra b437571714 Allow parallel CREATE INDEX for BRIN indexes
Allow using multiple worker processes to build BRIN index, which until
now was supported only for BTREE indexes. For large tables this often
results in significant speedup when the build is CPU-bound.

The work is split in a simple way - each worker builds BRIN summaries on
a subset of the table, determined by the regular parallel scan used to
read the data, and feeds them into a shared tuplesort which sorts them
by blkno (start of the range). The leader then reads this sorted stream
of ranges, merges duplicates (which may happen if the parallel scan does
not align with BRIN pages_per_range), and adds the resulting ranges into
the index.

The number of duplicate results produced by workers (requiring merging
in the leader process) should be fairly small, thanks to how parallel
scans assign chunks to workers. The likelihood of duplicate results may
increase for higher pages_per_range values, but then there are fewer
page ranges in total. In any case, we expect the merging to be much
cheaper than summarization, so this should be a win.

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

This also introduces a new index AM flag amcanbuildparallel, determining
whether to attempt to start parallel workers for the index build.

Original patch by me, with reviews and substantial reworks 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
Discussion: https://postgr.es/m/c2ee7d69-ce17-43f2-d1a0-9811edbda6e6%40enterprisedb.com
2023-12-08 18:15:26 +01:00
..
amapi.h Allow parallel CREATE INDEX for BRIN indexes 2023-12-08 18:15:26 +01:00
amvalidate.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
attmap.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
attnum.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
brin.h Allow parallel CREATE INDEX for BRIN indexes 2023-12-08 18:15:26 +01:00
brin_internal.h Reuse BrinDesc and BrinRevmap in brininsert 2023-11-25 20:27:28 +01:00
brin_page.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
brin_pageops.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
brin_revmap.h Remove some more "snapshot too old" vestiges. 2023-09-08 17:12:12 +12:00
brin_tuple.h Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
brin_xlog.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
bufmask.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
clog.h Index SLRUs by 64-bit integers rather than by 32-bit integers 2023-11-29 01:40:56 +02:00
commit_ts.h Index SLRUs by 64-bit integers rather than by 32-bit integers 2023-11-29 01:40:56 +02:00
detoast.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
genam.h Reuse BrinDesc and BrinRevmap in brininsert 2023-11-25 20:27:28 +01:00
generic_xlog.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
gin.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
gin_private.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
ginblock.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
ginxlog.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
gist.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
gist_private.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
gistscan.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
gistxlog.h Add info in WAL records in preparation for logical slot conflict handling 2023-04-02 12:32:19 -07:00
hash.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
hash_xlog.h Add info in WAL records in preparation for logical slot conflict handling 2023-04-02 12:32:19 -07:00
heapam.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
heapam_xlog.h Fix xl_heap_lock WAL record field's data type. 2023-04-11 14:07:54 -07:00
heaptoast.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
hio.h hio: Take number of prior relation extensions into account 2023-08-14 11:33:09 -07:00
htup.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
htup_details.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
itup.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
multixact.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
nbtree.h Skip checking of scan keys required for directional scan in B-tree 2023-10-06 10:40:51 +03:00
nbtxlog.h Fix incorrect comment about nbtree WAL record. 2023-04-17 09:58:18 -07:00
parallel.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
printsimple.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
printtup.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
relation.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
reloptions.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
relscan.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
rewriteheap.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
rmgr.h Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
rmgrdesc_utils.h Add rmgrdesc README 2023-10-02 12:18:57 +03:00
rmgrlist.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sdir.h Remove dead NoMovementScanDirection code 2023-02-01 10:52:41 +13:00
session.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
skey.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
slru.h Index SLRUs by 64-bit integers rather than by 32-bit integers 2023-11-29 01:40:56 +02:00
spgist.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
spgist_private.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
spgxlog.h Add info in WAL records in preparation for logical slot conflict handling 2023-04-02 12:32:19 -07:00
stratnum.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
subtrans.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
syncscan.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sysattr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
table.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tableam.h Fix assertions with RI triggers in heap_update and heap_delete. 2023-11-28 12:00:14 +02:00
timeline.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
toast_compression.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
toast_helper.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
toast_internals.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
transam.h Rename ShmemVariableCache to TransamVariables 2023-12-08 09:47:15 +02:00
tsmapi.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tupconvert.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tupdesc.h Move BuildDescForRelation() from tupdesc.c to tablecmds.c 2023-10-05 16:20:46 +02:00
tupdesc_details.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tupmacs.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
twophase.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
twophase_rmgr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
valid.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
visibilitymap.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
visibilitymapdefs.h Add info in WAL records in preparation for logical slot conflict handling 2023-04-02 12:32:19 -07:00
xact.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlog.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlog_internal.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlogarchive.h Revert refactoring of restore command code to shell_restore.c 2023-02-06 08:28:42 +09:00
xlogbackup.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
xlogdefs.h Improve the naming in wal_sync_method code. 2023-10-13 15:16:45 -05:00
xloginsert.h Assert that buffers are marked dirty before XLogRegisterBuffer(). 2023-10-23 17:17:46 -07:00
xlogprefetcher.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlogreader.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlogrecord.h Correct assertion and comments about XLogRecordMaxSize. 2023-10-01 12:20:55 -07:00
xlogrecovery.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xlogstats.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
xlogutils.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00