From: Niels Jespersen <NJN@dst.dk>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: cpu-intensive immutable function and parallel scan
Date: Tue, 22 Jun 2021 07:06:10 +0000
Message-ID: <c800b7a24a95419aaebf4e6ec31d8f57@dst.dk> (raw)
Hello all
I have a cpu-intensive plpython3u function that computes a result on the value from a single column value from a simple select.This looks largely like this.
select function_name (t1.val1, 'constant1') from t1 where t1.p = '202012_1' and t1.val1 is not null;
The function is marked immutable and parallel safe.
The time spent in the function is quite substantial. The same execution plan for a query that invokes the funtion and a query that does not results in a 15-times slowdown. Explain analyze show that both queries use 5 parallel workers.
I think I could achieve some speedup by parallelizing further, distributing the cpu-work among additional workers. But, how do I achive that best?
In Oracle I would either use a parallel-hint or an alter session force parallel query parallel 8.
Regards Niels
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: NJN@dst.dk
Subject: Re: cpu-intensive immutable function and parallel scan
In-Reply-To: <c800b7a24a95419aaebf4e6ec31d8f57@dst.dk>
References: <c800b7a24a95419aaebf4e6ec31d8f57@dst.dk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox