postgresql/src/include/utils
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
..
.gitignore Generate automatically code and documentation related to wait events 2023-07-05 10:53:11 +09:00
acl.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
aclchk_internal.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
array.h Improve readability and error detection of array_in(). 2023-11-13 13:01:51 -05:00
arrayaccess.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
ascii.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
attoptcache.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
backend_progress.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
backend_status.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
builtins.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
bytea.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
cash.h Convert *GetDatum() and DatumGet*() macros to inline functions 2022-09-27 20:50:21 +02:00
catcache.h Make ResourceOwners more easily extensible. 2023-11-08 13:30:50 +02:00
combocid.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
conffiles.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
date.h Add back SQLValueFunction for SQL keywords 2023-05-17 10:19:17 +09:00
datetime.h Refactor datetime functions' timezone lookup code to reduce duplication. 2023-03-17 17:47:19 -04:00
datum.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
dsa.h Avoid type cheats for invalid dsa_handles and dshash_table_handles. 2023-01-25 11:48:38 -05:00
dynahash.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
elog.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
evtcache.h Add support event triggers on authenticated login 2023-10-16 03:18:22 +03:00
expandeddatum.h New header varatt.h split off from postgres.h 2023-01-10 05:54:36 +01:00
expandedrecord.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
float.h Doc: improve commentary about providing our own definitions of M_PI. 2023-01-08 16:25:33 -05:00
fmgrtab.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
formatting.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
freepage.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
geo_decls.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
guc.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
guc_hooks.h Prohibit max_slot_wal_keep_size to value other than -1 during upgrade. 2023-11-10 08:45:01 +05:30
guc_tables.h Be more wary about NULL values for GUC string variables. 2023-11-02 11:47:33 -04:00
help_config.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
hsearch.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
index_selfuncs.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
inet.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
inval.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
json.h Add const to values and nulls arguments 2023-10-10 07:50:43 +02:00
jsonb.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
jsonfuncs.h Improve JsonLexContext's freeability 2023-10-05 10:59:08 +02:00
jsonpath.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
logtape.h Change logtape/tuplestore code to use int64 for block numbers 2023-11-17 11:20:53 +09:00
lsyscache.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
memdebug.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
memutils.h Retire MemoryContextResetAndDeleteChildren() macro. 2023-11-15 13:42:30 -06:00
memutils_internal.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
memutils_memorychunk.h Fix various typos 2023-04-18 13:23:23 +12:00
meson.build Replace Gen_dummy_probes.sed with Gen_dummy_probes.pl 2023-11-14 10:27:10 +01:00
multirangetypes.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
numeric.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
palloc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
partcache.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_crc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_locale.h All supported systems have locale_t. 2023-07-09 11:55:18 +12:00
pg_lsn.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_rusage.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
pgstat_internal.h Fix various typos and incorrect/outdated name references 2023-04-19 13:50:33 +12:00
pidfile.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
plancache.h Make ResourceOwners more easily extensible. 2023-11-08 13:30:50 +02:00
portal.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
ps_status.h Speedup and increase usability of set proc title functions 2023-02-20 16:18:27 +13:00
queryenvironment.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
rangetypes.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
regproc.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
rel.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
relcache.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
relfilenumbermap.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
relmapper.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
relptr.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
reltrigger.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
resowner.h Use ResourceOwner to track WaitEventSets. 2023-11-23 13:31:36 +02:00
resowner_private.h bufmgr: Support multiple in-progress IOs by using resowner 2023-04-05 14:17:55 -07:00
rls.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
ruleutils.h pageinspect: Fix gist_page_items() with included columns 2023-05-19 12:37:58 +09:00
sampling.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
selfuncs.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
sharedtuplestore.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
snapmgr.h Remove the "snapshot too old" feature. 2023-09-05 19:53:43 +12:00
snapshot.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
sortsupport.h Fix various typos and incorrect/outdated name references 2023-04-19 13:50:33 +12:00
spccache.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
syscache.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
timeout.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
timestamp.h Add back SQLValueFunction for SQL keywords 2023-05-17 10:19:17 +09:00
tuplesort.h Allow parallel CREATE INDEX for BRIN indexes 2023-12-08 18:15:26 +01:00
tuplestore.h Retire a few backwards compatibility macros. 2023-11-27 13:10:09 -06:00
typcache.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
tzparser.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
usercontext.h Perform logical replication actions as the table owner. 2023-04-04 11:25:23 -04:00
uuid.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
varbit.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
varlena.h Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
wait_event.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
xid8.h Update copyright for 2023 2023-01-02 15:00:37 -05:00
xml.h Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00