Re: Parallel CREATE INDEX for BRIN indexes

2024-04-17 Thread Tomas Vondra
On 4/15/24 20:35, Tomas Vondra wrote: > ... > > Attached is the cleanup I thought about doing earlier in this patch [1] > to make the code more like btree. The diff might make it seem like a big > change, but it really just moves the merge code into a separate function > and makes it use using the

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-17 Thread Tomas Vondra
On 4/16/24 22:33, Tomas Vondra wrote: > On 4/15/24 20:35, Tomas Vondra wrote: >> On 4/15/24 10:18, Tomas Vondra wrote: > > ... > > That is, no parallel index builds on temporary tables. Which means the > test is not actually testing anything :-( Much more stable, but not very > useful for finding

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-16 Thread Tomas Vondra
On 4/15/24 20:35, Tomas Vondra wrote: > On 4/15/24 10:18, Tomas Vondra wrote: >> ... >> >> I'll try a bit more to make this work without the temp table. >> > > Considering the earlier discussion in e2933a6e1, I think making the > table TEMP is the best fix, so I'll do that. Thanks for remembering

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-15 Thread Tomas Vondra
On 4/15/24 10:18, Tomas Vondra wrote: > ... > > I'll try a bit more to make this work without the temp table. > Considering the earlier discussion in e2933a6e1, I think making the table TEMP is the best fix, so I'll do that. Thanks for remembering that change, Alexander! Attached is the cleanup

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-15 Thread Tomas Vondra
On 4/15/24 08:00, Alexander LAW wrote: > Hello Tomas, > > 14.04.2024 20:09, Tomas Vondra wrote: >> I've pushed this, including backpatching the two fixes. I've reduced the >> amount of data needed by the test, and made sure it works on 32-bits too >> (I was a bit worried it might be sensitive

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-15 Thread Alexander Lakhin
Hello Tomas, 14.04.2024 20:09, Tomas Vondra wrote: I've pushed this, including backpatching the two fixes. I've reduced the amount of data needed by the test, and made sure it works on 32-bits too (I was a bit worried it might be sensitive to that, but that seems not to be the case). I've

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-14 Thread Tomas Vondra
I've pushed this, including backpatching the two fixes. I've reduced the amount of data needed by the test, and made sure it works on 32-bits too (I was a bit worried it might be sensitive to that, but that seems not to be the case). There's still the question of maybe removing the differences

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-13 Thread Tomas Vondra
On 4/13/24 11:19, Tomas Vondra wrote: > On 4/13/24 10:36, Andres Freund wrote: >> Hi, >> >> While preparing a differential code coverage report between 16 and HEAD, one >> thing that stands out is the parallel brin build code. Neither on >> coverage.postgresql.org nor locally is that code reached

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-13 Thread Tomas Vondra
On 4/13/24 10:36, Andres Freund wrote: > Hi, > > While preparing a differential code coverage report between 16 and HEAD, one > thing that stands out is the parallel brin build code. Neither on > coverage.postgresql.org nor locally is that code reached during our tests. > Thanks for pointing

Re: Parallel CREATE INDEX for BRIN indexes

2024-04-13 Thread Andres Freund
Hi, While preparing a differential code coverage report between 16 and HEAD, one thing that stands out is the parallel brin build code. Neither on coverage.postgresql.org nor locally is that code reached during our tests.

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-30 Thread Tomas Vondra
Hi, While cleaning up some unnecessary bits of the code and slightly inaccurate comments, I ran into a failure when the parallel scan (used by the parallel build) happened to be a synchronized scan. When the scan did not start on page 0, the parallel callback failed to correctly handle tuples

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-08 Thread Tomas Vondra
Hi, I've pushed the first two parts (backfill of empty ranges for serial builds, allowing parallelism) after a bit more cleanup, adding a simple pageinspect test to 0001, improving comments and some minor adjustments. I ended up removing the protections against BlockNumber overflows, and moved

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-04 Thread Tomas Vondra
On 12/4/23 16:00, Matthias van de Meent wrote: > On Sun, 3 Dec 2023 at 17:46, Tomas Vondra > wrote: >> On 11/30/23 18:47, Matthias van de Meent wrote: >>> ... >>> >>> I just ran some more tests in less favorable environments, and it >>> looks like I hit a bug: >>> >>> % SET

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-04 Thread Matthias van de Meent
On Sun, 3 Dec 2023 at 17:46, Tomas Vondra wrote: > On 11/30/23 18:47, Matthias van de Meent wrote: > > ... > > > > I just ran some more tests in less favorable environments, and it > > looks like I hit a bug: > > > > % SET max_parallel_workers = 0; > > % CREATE INDEX ... USING brin (...); > >

Re: Parallel CREATE INDEX for BRIN indexes

2023-12-03 Thread Tomas Vondra
On 11/30/23 18:47, Matthias van de Meent wrote: > ... > > I just ran some more tests in less favorable environments, and it > looks like I hit a bug: > > % SET max_parallel_workers = 0; > % CREATE INDEX ... USING brin (...); > ERROR: cannot update tuples during a parallel operation > > Fix

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-30 Thread Matthias van de Meent
On Thu, 30 Nov 2023 at 01:10, Tomas Vondra wrote: > > On 11/29/23 23:59, Matthias van de Meent wrote: >> On Wed, 29 Nov 2023 at 21:56, Tomas Vondra >> wrote: >>> >>> On 11/29/23 21:30, Matthias van de Meent wrote: On Wed, 29 Nov 2023 at 18:55, Tomas Vondra wrote: > I did try to

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 23:59, Matthias van de Meent wrote: > On Wed, 29 Nov 2023 at 21:56, Tomas Vondra > wrote: >> >> On 11/29/23 21:30, Matthias van de Meent wrote: >>> On Wed, 29 Nov 2023 at 18:55, Tomas Vondra >>> wrote: I did try to measure how much it actually saves, but none of the tests I

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Matthias van de Meent
On Wed, 29 Nov 2023 at 21:56, Tomas Vondra wrote: > > On 11/29/23 21:30, Matthias van de Meent wrote: >> On Wed, 29 Nov 2023 at 18:55, Tomas Vondra >> wrote: >>> I did try to measure how much it actually saves, but none of the tests I >>> did actually found measurable improvement. So I'm tempted

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 21:30, Matthias van de Meent wrote: > On Wed, 29 Nov 2023 at 18:55, Tomas Vondra > wrote: >> >> On 11/29/23 15:52, Tomas Vondra wrote: ... This also made me think a bit more about how we're working with the tuples. With your latest patch, we always deserialize and

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Matthias van de Meent
On Wed, 29 Nov 2023 at 18:55, Tomas Vondra wrote: > > On 11/29/23 15:52, Tomas Vondra wrote: > >> ... > >> > >> This also made me think a bit more about how we're working with the > >> tuples. With your latest patch, we always deserialize and re-serialize > >> the sorted brin tuples, just in case

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 15:52, Tomas Vondra wrote: >> ... >> >> This also made me think a bit more about how we're working with the >> tuples. With your latest patch, we always deserialize and re-serialize >> the sorted brin tuples, just in case the next tuple will also be a >> BRIN tuple of the same page

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Tomas Vondra
On 11/29/23 15:42, Matthias van de Meent wrote: > On Tue, 28 Nov 2023 at 18:59, Tomas Vondra > wrote: >> >> On 11/28/23 16:39, Matthias van de Meent wrote: >>> On Thu, 23 Nov 2023 at 14:35, Tomas Vondra >>> wrote: On 11/23/23 13:33, Matthias van de Meent wrote: > The union operator may

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-29 Thread Matthias van de Meent
On Tue, 28 Nov 2023 at 18:59, Tomas Vondra wrote: > > On 11/28/23 16:39, Matthias van de Meent wrote: > > On Thu, 23 Nov 2023 at 14:35, Tomas Vondra > > wrote: > >> On 11/23/23 13:33, Matthias van de Meent wrote: > >>> The union operator may leak (lots of) memory, so I think it makes > >>> sense

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-28 Thread Tomas Vondra
On 11/28/23 16:39, Matthias van de Meent wrote: > On Thu, 23 Nov 2023 at 14:35, Tomas Vondra > wrote: >> On 11/23/23 13:33, Matthias van de Meent wrote: >>> The union operator may leak (lots of) memory, so I think it makes >>> sense to keep a context around that can be reset after we've extracted

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-28 Thread Matthias van de Meent
On Thu, 23 Nov 2023 at 14:35, Tomas Vondra wrote: > On 11/23/23 13:33, Matthias van de Meent wrote: >> The union operator may leak (lots of) memory, so I think it makes >> sense to keep a context around that can be reset after we've extracted >> the merge result. >> > > But does the current code

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-23 Thread Tomas Vondra
On 11/23/23 13:33, Matthias van de Meent wrote: > Hi, > > On Wed, 22 Nov 2023 at 20:16, Tomas Vondra > wrote: >> >> On 11/20/23 20:48, Matthias van de Meent wrote: >>> On Wed, 8 Nov 2023 at 12:03, Tomas Vondra >>> wrote: Hi, here's an updated patch, addressing the review

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-23 Thread Matthias van de Meent
Hi, On Wed, 22 Nov 2023 at 20:16, Tomas Vondra wrote: > > On 11/20/23 20:48, Matthias van de Meent wrote: >> On Wed, 8 Nov 2023 at 12:03, Tomas Vondra >> wrote: >>> >>> Hi, >>> >>> here's an updated patch, addressing the review comments, and reworking >>> how the work is divided between the

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-22 Thread Tomas Vondra
On 11/20/23 20:48, Matthias van de Meent wrote: > On Wed, 8 Nov 2023 at 12:03, Tomas Vondra > wrote: >> >> Hi, >> >> here's an updated patch, addressing the review comments, and reworking >> how the work is divided between the workers & leader etc. >> >> 0001 is just v2, rebased to current

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-20 Thread Matthias van de Meent
On Wed, 8 Nov 2023 at 12:03, Tomas Vondra wrote: > > Hi, > > here's an updated patch, addressing the review comments, and reworking > how the work is divided between the workers & leader etc. > > 0001 is just v2, rebased to current master > > 0002 and 0003 address most of the issues, in

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-12 Thread Tomas Vondra
On 11/12/23 10:38, Matthias van de Meent wrote: > On Wed, 8 Nov 2023 at 12:03, Tomas Vondra > wrote: >> >> Hi, >> >> here's an updated patch, addressing the review comments, and reworking >> how the work is divided between the workers & leader etc. > > Thanks! > >> In general I'm quite

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-12 Thread Matthias van de Meent
On Wed, 8 Nov 2023 at 12:03, Tomas Vondra wrote: > > Hi, > > here's an updated patch, addressing the review comments, and reworking > how the work is divided between the workers & leader etc. Thanks! > In general I'm quite happy with the current state, and I believe it's > fairly close to be

Re: Parallel CREATE INDEX for BRIN indexes

2023-11-08 Thread Tomas Vondra
Hi, here's an updated patch, addressing the review comments, and reworking how the work is divided between the workers & leader etc. 0001 is just v2, rebased to current master 0002 and 0003 address most of the issues, in particular it - removes the unnecessary spool - fixes bs_reltuples

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-14 Thread Matthias van de Meent
On Fri, 14 Jul 2023 at 15:57, Tomas Vondra wrote: > > On 7/11/23 23:11, Matthias van de Meent wrote: >> On Thu, 6 Jul 2023 at 16:13, Tomas Vondra >> wrote: >>> >>> One thing I was wondering about is whether it might be better to allow >>> the workers to process overlapping ranges, and then let

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-14 Thread Tomas Vondra
On 7/11/23 23:11, Matthias van de Meent wrote: > On Thu, 6 Jul 2023 at 16:13, Tomas Vondra > wrote: >> >> On 7/5/23 16:33, Matthias van de Meent wrote: >>> ... >>> Maybe. I wasn't that familiar with what parallel tuplesort can and can't do, and the little I knew I managed to forget

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-11 Thread Matthias van de Meent
On Thu, 6 Jul 2023 at 16:13, Tomas Vondra wrote: > > On 7/5/23 16:33, Matthias van de Meent wrote: > > ... > > > >> Maybe. I wasn't that familiar with what parallel tuplesort can and can't > >> do, and the little I knew I managed to forget since I wrote this patch. > >> Which similar features do

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-06 Thread Tomas Vondra
On 7/5/23 16:33, Matthias van de Meent wrote: > ... > >> Maybe. I wasn't that familiar with what parallel tuplesort can and can't >> do, and the little I knew I managed to forget since I wrote this patch. >> Which similar features do you have in mind? > > I was referring to the feature that is

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-05 Thread Matthias van de Meent
On Wed, 5 Jul 2023 at 00:08, Tomas Vondra wrote: > > > > On 7/4/23 23:53, Matthias van de Meent wrote: > > On Thu, 8 Jun 2023 at 14:55, Tomas Vondra > > wrote: > >> > >> Hi, > >> > >> Here's a WIP patch allowing parallel CREATE INDEX

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-05 Thread Tomas Vondra
On 7/5/23 10:44, Matthias van de Meent wrote: > On Wed, 5 Jul 2023 at 00:08, Tomas Vondra > wrote: >> >> >> >> On 7/4/23 23:53, Matthias van de Meent wrote: >>> On Thu, 8 Jun 2023 at 14:55, Tomas Vondra >>> wrote: >>>> >>

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-05 Thread Matthias van de Meent
On Wed, 5 Jul 2023 at 00:08, Tomas Vondra wrote: > > > > On 7/4/23 23:53, Matthias van de Meent wrote: > > On Thu, 8 Jun 2023 at 14:55, Tomas Vondra > > wrote: > >> > >> Hi, > >> > >> Here's a WIP patch allowing parallel CREATE INDEX

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-04 Thread Tomas Vondra
On 7/4/23 23:53, Matthias van de Meent wrote: > On Thu, 8 Jun 2023 at 14:55, Tomas Vondra > wrote: >> >> Hi, >> >> Here's a WIP patch allowing parallel CREATE INDEX for BRIN indexes. The >> infrastructure (starting workers etc.) is "inspire

Re: Parallel CREATE INDEX for BRIN indexes

2023-07-04 Thread Matthias van de Meent
On Thu, 8 Jun 2023 at 14:55, Tomas Vondra wrote: > > Hi, > > Here's a WIP patch allowing parallel CREATE INDEX for BRIN indexes. The > infrastructure (starting workers etc.) is "inspired" by the BTREE code > (i.e. copied from that and massaged a bit to call brin st

Parallel CREATE INDEX for BRIN indexes

2023-06-08 Thread Tomas Vondra
Hi, Here's a WIP patch allowing parallel CREATE INDEX for BRIN indexes. The infrastructure (starting workers etc.) is "inspired" by the BTREE code (i.e. copied from that and massaged a bit to call brin stuff). _bt_begin_parallel -> _brin_begin_parallel _bt_end_parallel -> _b