forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitb437571
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.com1 parentdae761a commitb437571
File tree
16 files changed
+1118
-16
lines changed- contrib/bloom
- doc/src/sgml
- src
- backend
- access
- brin
- gin
- gist
- hash
- nbtree
- spgist
- transam
- catalog
- utils/sort
- include
- access
- utils
- test/modules/dummy_index_am
- tools/pgindent
16 files changed
+1118
-16
lines changedLines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
122 | 122 |
| |
123 | 123 |
| |
124 | 124 |
| |
| 125 | + | |
125 | 126 |
| |
126 | 127 |
| |
127 | 128 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
123 | 123 |
| |
124 | 124 |
| |
125 | 125 |
| |
| 126 | + | |
| 127 | + | |
126 | 128 |
| |
127 | 129 |
| |
128 | 130 |
| |
| |||
286 | 288 |
| |
287 | 289 |
| |
288 | 290 |
| |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
289 | 296 |
| |
290 | 297 |
| |
291 | 298 |
| |
|
0 commit comments
Comments
(0)