parallel plpgsql function

From: Jiří Fejfar <jurafejfar(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: parallel plpgsql function
Date: 2019-01-29 17:35:47
Message-ID: CA+8wVNXBxNQOcLOzY2N80yvTE_+w_zRqQu30Jp=mMd=w57defA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Stefan Keller 2019-01-29 18:03:33 Re: How to set parameters in 'options'?
Previous Message Gunnar "Nick" Bluth 2019-01-29 16:55:29 Re: SELECT of pseudo hex value gives unexpected result