>From: Ondrej Ivanič <ondrej.iva...@gmail.com> >Sent: Saturday, December 7, 2019 2:23 AM
>Cc: pgsql-performance@lists.postgresql.org ><pgsql-performance@lists.postgresql.org> >Subject: Re: How to run in parallel in Postgres > >Hi Lars, > >I have two suggestions: > >- `xargs` almost always present and it can run in parallel (-P) but script >needs to be changed: >for((i=1;i<=28;i++)); do echo "SELECT >find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',${I},28);"; > done | xargs -n1 -P 10 psql ... > >- `UNION ALL` might trigger parallel execution (you need to mess with the >cost of the function and perhaps other settings): >SELECT > find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',1,28) >UNION ALL >SELECT > find_overlap_gap_single_cell('test_data.overlap_gap_input_t1','geom',4258,'test_data.overlap_gap_input_t1_res',2,28) >... > > >Cheers, > Hi Ondrej * Yes using xargs seems be an alternative to GNU parallel and I will have that in mind. * I did a test using UNION ALL in the branch https://github.com/larsop/find-overlap-and-gap/tree/union_all_parallel but I was not able to trigger Postgres parallel . That may be related to what Justin say about create tables. Thanks. Lars