Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb437571

Browse files
committed
Allow parallel CREATE INDEX for BRIN indexes
Allow using multiple worker processes to build BRIN index, which untilnow was supported only for BTREE indexes. For large tables this oftenresults in significant speedup when the build is CPU-bound.The work is split in a simple way - each worker builds BRIN summaries ona subset of the table, determined by the regular parallel scan used toread the data, and feeds them into a shared tuplesort which sorts themby blkno (start of the range). The leader then reads this sorted streamof ranges, merges duplicates (which may happen if the parallel scan doesnot align with BRIN pages_per_range), and adds the resulting ranges intothe index.The number of duplicate results produced by workers (requiring mergingin the leader process) should be fairly small, thanks to how parallelscans assign chunks to workers. The likelihood of duplicate results mayincrease for higher pages_per_range values, but then there are fewerpage ranges in total. In any case, we expect the merging to be muchcheaper than summarization, so this should be a win.Most of the parallelism infrastructure is a simplified copy of the codeused by BTREE indexes, omitting the parts irrelevant for BRIN indexes(e.g. uniqueness checks).This also introduces a new index AM flag amcanbuildparallel, determiningwhether to attempt to start parallel workers for the index build.Original patch by me, with reviews and substantial reworks by Matthiasvan de Meent, certainly enough to make him a co-author.Author: Tomas Vondra, Matthias van de MeentReviewed-by: Matthias van de MeentDiscussion:https://postgr.es/m/c2ee7d69-ce17-43f2-d1a0-9811edbda6e6%40enterprisedb.com
1 parentdae761a commitb437571

File tree

16 files changed

+1118
-16
lines changed

16 files changed

+1118
-16
lines changed

‎contrib/bloom/blutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ blhandler(PG_FUNCTION_ARGS)
122122
amroutine->amclusterable= false;
123123
amroutine->ampredlocks= false;
124124
amroutine->amcanparallel= false;
125+
amroutine->amcanbuildparallel= false;
125126
amroutine->amcaninclude= false;
126127
amroutine->amusemaintenanceworkmem= false;
127128
amroutine->amparallelvacuumoptions=

‎doc/src/sgml/indexam.sgml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ typedef struct IndexAmRoutine
123123
bool ampredlocks;
124124
/* does AM support parallel scan? */
125125
bool amcanparallel;
126+
/* does AM support parallel build? */
127+
bool amcanbuildparallel;
126128
/* does AM support columns included with clause INCLUDE? */
127129
bool amcaninclude;
128130
/* does AM use maintenance_work_mem? */
@@ -286,6 +288,11 @@ ambuild (Relation heapRelation,
286288
and compute the keys that need to be inserted into the index.
287289
The function must return a palloc'd struct containing statistics about
288290
the new index.
291+
The <structfield>amcanbuildparallel</structfield> flag indicates whether
292+
the access method supports parallel index builds. When set to <literal>true</literal>,
293+
the system will attempt to allocate parallel workers for the build.
294+
Access methods supporting only non-parallel index builds should leave
295+
this flag set to <literal>false</literal>.
289296
</para>
290297

291298
<para>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp