Re: How to run in parallel in Postgres, EXECUTE_PARALLEL - Mailing list pgsql-performance

From Lars Aksel Opsahl
Subject Re: How to run in parallel in Postgres, EXECUTE_PARALLEL
Date
Msg-id HE1P189MB0266588071668BF3D5CF85479D590@HE1P189MB0266.EURP189.PROD.OUTLOOK.COM
Whole thread Raw
In response to Re: How to run in parallel in Postgres  (Laurenz Albe <laurenz.albe@cybertec.at>)
Responses Re: How to run in parallel in Postgres, EXECUTE_PARALLEL  (Joe Conway <mail@joeconway.com>)
List pgsql-performance
>You cannot run several queries in parallel in a PostgreSQL function.
>
>You may want to have a look at PL/Proxy which might be used for things like that.
>
>Yours,
>Laurenz Albe
>--
>Cybertec | https://www.cybertec-postgresql.com

Hi Laurenz

The code below takes 3, seconds 
DO

$body$

DECLARE 

BEGIN

EXECUTE 'SELECT pg_sleep(1); SELECT pg_sleep(1); SELECT pg_sleep(1);';

END

$body$;

Do you or anybody know if there are any plans for a function call that support the calling structure below or something like it and that then could finish in 1 second ? (If you are calling a void function, the return value should not be any problem.)

DO

$body$

DECLARE 

command_string_list text[3];

BEGIN

command_string_list[0] = 'SELECT pg_sleep(1)';

command_string_list[1] = 'SELECT pg_sleep(1)';

command_string_list[2] = 'SELECT pg_sleep(1)';

EXECUTE_PARALLEL command_string_list;

END

$body$;


The only way to this today as I understand it, is to open 3 new connections back to the database which you can be done in different ways. 
 
If we had a parallel functions like the one above it's easier to make parallel sql without using complex scripts, java, python or other system.

Thanks.

Lars

pgsql-performance by date:

Previous
From: Tom Lane
Date:
Subject: Re: query that canceled isnt logged
Next
From: Joe Conway
Date:
Subject: Re: How to run in parallel in Postgres, EXECUTE_PARALLEL