pgsql: Improve access to parallel query from procedural languages.

From: Robert Haas <rhaas(at)postgresql(dot)org>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve access to parallel query from procedural languages.
Date: 2017-03-24 18:49:39
Message-ID: E1crUHL-0004xN-Eo@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Improve access to parallel query from procedural languages.

In SQL, the ability to use parallel query was previous contingent on
fcache->readonly_func, which is only set for non-volatile functions;
but the volatility of a function has no bearing on whether queries
inside it can use parallelism. Remove that condition.

SPI_execute and SPI_execute_with_args always run the plan just once,
though not necessarily to completion. Given the changes in commit
691b8d59281b5177f16fe80858df921f77a8e955, it's sensible to pass
CURSOR_OPT_PARALLEL_OK here, so do that. This improves access to
parallelism for any caller that uses these functions to execute
queries. Such callers include plperl, plpython, pltcl, and plpgsql,
though it's not the case that they all use these functions
exclusively.

In plpgsql, allow parallel query for plain SELECT queries (as
opposed to PERFORM, which already worked) and for plain expressions
(which probably won't go through the executor at all, because they
will likely be simple expressions, but if they do then this helps).

Rafia Sabih and Robert Haas, reviewed by Dilip Kumar and Amit Kapila

Discussion: http://postgr.es/m/CAOGQiiMfJ+4SQwgG=6CVHWoisiU0+7jtXSuiyXBM3y=A=eJzmg@mail.gmail.com

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/61c2e1a95f94bb904953a6281ce17a18ac38ee6d

Modified Files
--------------
src/backend/executor/functions.c | 2 +-
src/backend/executor/spi.c | 4 ++--
src/pl/plpgsql/src/pl_exec.c | 30 +++++++++++++++++-------------
3 files changed, 20 insertions(+), 16 deletions(-)

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Peter Eisentraut 2017-03-24 18:52:17 pgsql: Check that published table exists on subscriber
Previous Message Robert Haas 2017-03-24 18:46:02 Re: [COMMITTERS] pgsql: Implement multivariate n-distinct coefficients

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2017-03-24 18:49:42 Re: Enabling parallelism for queries coming from SQL or other PL functions
Previous Message Robert Haas 2017-03-24 18:46:02 Re: [COMMITTERS] pgsql: Implement multivariate n-distinct coefficients