Re: Retrieve results in PostgreSQL stored procedure allowing query parallelism - Mailing list pgsql-general

From David G. Johnston
Subject Re: Retrieve results in PostgreSQL stored procedure allowing query parallelism
Date
Msg-id CAKFQuwaXoR=Rzh+dGRWBxUxuAtriqsfDGdSC=z+OyShAHPzfUQ@mail.gmail.com
Whole thread Raw
In response to Retrieve results in PostgreSQL stored procedure allowing query parallelism  (Joan Pujol <joanpujol@gmail.com>)
Responses Re: Retrieve results in PostgreSQL stored procedure allowing query parallelism
List pgsql-general
On Tue, Nov 21, 2023, 11:10 Joan Pujol <joanpujol@gmail.com> wrote:
I want to execute an SQL query and process its results inside a stored
procedure without preventing query parallelism. Since I don't want to
prevent query parallelism, cursors can't be used, and I would like to
avoid creating a temporal table.

Is this possible? If so, what is the best way to execute the query,
retrieve all results in memory, and process them inside the stored
procedure?

You must use create table as if you want a result that is both accessible to subsequent statements and uses parallelism to be produced.  There is no saving results into memory - you either save them explicitly or iterate over them and the later prevents parallelism as you've noted.

David J.

pgsql-general by date:

Previous
From: Joan Pujol
Date:
Subject: Retrieve results in PostgreSQL stored procedure allowing query parallelism
Next
From: Joan Pujol
Date:
Subject: Re: Retrieve results in PostgreSQL stored procedure allowing query parallelism