postgresql/src/backend/catalog
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 Build in some knowledge about foreign-key relationships in the catalogs. 2021-02-02 17:11:55 -05:00
Catalog.pm Restructure DECLARE_INDEX arguments 2023-08-31 08:14:57 +02:00
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
aclchk.c Harden has_xxx_privilege() functions against concurrent object drops. 2023-10-14 14:49:50 -04:00
catalog.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
dependency.c Remove useless casts to (void *) in arguments of some system functions 2023-02-07 06:57:59 +01:00
genbki.pl genbki.pl: Factor out boilerplate generation 2023-08-31 10:21:34 +02:00
heap.c Ensure we preprocess expressions before checking their volatility. 2023-11-16 10:05:14 -05:00
index.c Allow parallel CREATE INDEX for BRIN indexes 2023-12-08 18:15:26 +01:00
indexing.c Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
information_schema.sql Simplify information schema check constraint deparsing 2023-09-22 07:43:26 +02:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00
namespace.c Optimize SearchPathCache by saving the last entry. 2023-12-04 17:19:16 -08:00
objectaccess.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
objectaddress.c Fill in more of ObjectProperty 2023-10-30 06:08:53 -04:00
partition.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_aggregate.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_attrdef.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_cast.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_class.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_collation.c Allow tailoring of ICU locales with custom rules 2023-03-08 16:56:37 +01:00
pg_constraint.c Disallow changing NO INHERIT status of a not-null constraint 2023-08-29 19:19:24 +02:00
pg_conversion.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_db_role_setting.c Revert "Add USER SET parameter values for pg_db_role_setting" 2023-05-17 20:28:57 +03:00
pg_depend.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_enum.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_inherits.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_largeobject.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_namespace.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_operator.c Extend ALTER OPERATOR to allow setting more optimization attributes. 2023-10-20 12:28:46 -04:00
pg_parameter_acl.c Allow ALTER SYSTEM to set unrecognized custom GUCs. 2023-10-21 13:35:19 -04:00
pg_proc.c Revert "Add USER SET parameter values for pg_db_role_setting" 2023-05-17 20:28:57 +03:00
pg_publication.c Fix various typos and incorrect/outdated name references 2023-04-19 13:50:33 +12:00
pg_range.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
pg_shdepend.c Add trailing commas to enum definitions 2023-10-26 09:20:54 +02:00
pg_subscription.c Restart the apply worker if the privileges have been revoked. 2023-10-17 08:41:44 +05:30
pg_type.c Update copyright for 2023 2023-01-02 15:00:37 -05:00
sql_feature_packages.txt Update SQL features 2023-05-02 10:59:21 +02:00
sql_features.txt Add XMLText function (SQL/XML X038) 2023-11-06 09:38:29 +01:00
storage.c Remove unnecessary smgrimmedsync() when creating unlogged table. 2023-09-15 17:29:37 +03:00
system_functions.sql Add support for pg_stat_reset_slru without argument 2023-11-14 09:50:52 +09:00
system_views.sql Display length and bounds histograms in pg_stats 2023-11-27 01:32:17 +02:00
toasting.c Remove IndexInfo.ii_OpclassOptions field 2023-10-03 17:51:02 +02:00