How to run in parallel in Postgres - Mailing list pgsql-performance

From Lars Aksel Opsahl
Subject How to run in parallel in Postgres
Date
Msg-id HE1P189MB026622ECFF2400B1932E4A2D9D5D0@HE1P189MB0266.EURP189.PROD.OUTLOOK.COM
Whole thread Raw
Responses Re: How to run in parallel in Postgres  (Laurenz Albe <laurenz.albe@cybertec.at>)
Re: How to run in parallel in Postgres  (Ondrej Ivanič <ondrej.ivanic@gmail.com>)
Re: How to run in parallel in Postgres  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-performance
Hi

I have a function that prepares data, so the big job can be run it in parallel. 

Today I have solved this by using "Gnu parallel" like this.
psql testdb -c"\! psql -t -q -o /tmp/run_cmd.sql testdb -c\"SELECT find_overlap_gap_make_run_cmd('sl_lop.overlap_gap_input_t1','geom',4258,'sl_lop.overlap_gap_input_t1_res',50);\"; parallel -j 4  psql testdb -c :::: /tmp/run_cmd.sql" 2>> /tmp/analyze.log;

The problem here is that I depend on external code which may not be installed. 

Since Postgres now supports parallel I was wondering if it's easy to trigger parallel dynamically created SQL calls.

If you look at https://github.com/larsop/find-overlap-and-gap/blob/master/src/test/sql/regress/find_overlap_and_gap.sql  you see that

find_overlap_gap_make_run_cmd generates as set of 28 sql calls. 


So is it in a simple way possible to use Postgres parallel functionality to call this 28 functions i parallel so I don't have dependent on externally install programs  ?


When this 28 sql calls are done, the find_overlap_gap_make_run_cmd may continue to the next step of work. So the function that triggers parallel calls wait for them complete and then may start on the next step of work.


Thanks .


Lars



 

   

pgsql-performance by date:

Previous
From: Andres Freund
Date:
Subject: Re: performance degredation after upgrade from 9.6 to 12
Next
From: Laurenz Albe
Date:
Subject: Re: How to run in parallel in Postgres