parallel plpgsql function - Mailing list pgsql-general

From Jiří Fejfar
Subject parallel plpgsql function
Date
Msg-id CA+8wVNXBxNQOcLOzY2N80yvTE_+w_zRqQu30Jp=mMd=w57defA@mail.gmail.com
Whole thread Raw
List pgsql-general
Hi all!

I am trying to create basic experiment [1] analysing some data with plpgsql function in parallel.

I am able to aggregate data in parallel (6 workers) with pure SQL code (line 19) but as far as I put the same query (with some parametrization) into plpgsql function and run it via RETURN QUERY EXECUTE it doesn't run in parallel anymore (line 69). I would understand, that planner doesn't see into dynamic SQL being executed here or something like this.

But what is more surprising to me is, when I am trying to call that function 10x with different settings (line 84). It is also running on single CPU (probably according to 10x longer execution time) although the function is marked as PARALLEL SAFE.

I hope that at least the second example can be parallelized without any "conceptual" problems. Do I miss something?

And one last question: is it possible to see query plan which is created "inside" function call when query is actually executed?

Thank you in advance, Jiří.

[1] https://gitlab.com/snippets/1806432

pgsql-general by date:

Previous
From: "Gunnar \"Nick\" Bluth"
Date:
Subject: Re: SELECT of pseudo hex value gives unexpected result
Next
From: Stefan Keller
Date:
Subject: Re: How to set parameters in 'options'?