Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

2020-12-01 Thread mobigroup
Tom, Ok, but how about reading from temporary tables? We could mark the function as "PARALLEL SAFE” instead of "PARALLEL RESTRICTED” in this case if it’s important. Actually, I rewrote the function without temp tables access but that’s not helpful - the function marked as "PARALLEL SAFE” is not

Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

2020-12-01 Thread Tom Lane
mobigroup writes: >> Perhaps you didn't define it as PARALLEL SAFE. > The function is marked as "PARALLEL RESTRICTED” because it’s uses temp tables > (and I tested it as PARALLEL SAFE with the same result… parallelisation > doesn’t work anyway). If it writes into temp tables then it can't be r

Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

2020-12-01 Thread mobigroup
Thanks for the ideas, I tested them: > > The essential question here is when the function is executed, so you should > use > EXPLAIN (VERBOSE) to see that. Append (cost=0.00..5.12 rows=4 width=32) -> Gather (cost=0.00..1.26 rows=1 width=32) Output: plpgsql_function(...) Work

Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

2020-12-01 Thread Laurenz Albe
On Tue, 2020-12-01 at 14:38 +0700, mobigroup wrote: > I have strange behaviour when EXPLAIN returns parallel execution plan but the > query execution is not parallel. The query looks as > > SELECT > plpgsql_function(...parameters…) > FROM table as t > WHERE id=

PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

2020-11-30 Thread mobigroup
Hi, I have strange behaviour when EXPLAIN returns parallel execution plan but the query execution is not parallel. The query looks as SELECT plpgsql_function(...parameters…) FROM table as t WHERE id=1 UNION ALL SELECT plpgsql_functi

Re: Parallel query and number of connections.

2018-11-21 Thread Adrian Klaver
ry is duplicated and not referring to multiple queries issued. The only difference is obviosly the pid and client_addr, that is populated in any of the connections but the first one. client_addr being different would seem to indicate that this is something other then parallel query.

Parallel query and number of connections.

2018-11-21 Thread Alessandro Aste
Hi there, we are running postgresql 10.5 on a centos 7 server. We're seeing multiple connections (in pg_stat_activity) from our application with the same query , same user, same application_name, same query_start etc. We are 100% sure the query is duplicated and not referring to multiple queries

Re: Parallel Query - Can it be used within functions?

2018-02-28 Thread Michael Krüger
Ok, to close this thread. The problem is, that plpgsql function do seem to return data using a cursor. That fact is disabling parallel execution. So if we instead hand over the SQL to a function with e.g. a python body, then parallel execution is happening, because the data is first assembled in me

Re: Parallel Query - Can it be used within functions?

2018-02-28 Thread Michael Krüger
ah, and for completeness the simple python function I use for the test: create or replace function reports.generic_query_python(_sql text) RETURNS SETOF record LANGUAGE 'plpythonu' PARALLEL SAFE COST 100 VOLATILE ROWS 5000 AS $BODY$ return plpy.execute( _sql ) $BODY$; Michael Krü

Re: Parallel Query - Can it be used within functions?

2018-02-16 Thread Michael Krüger
Dear all, still same behavior with Postgres 10.2 ... Just as a reminder that the issue still exists. Regards, Michael Andreas Kretschmer schrieb am Di., 6. Feb. 2018 um 08:35 Uhr: > Hi, > > > Am 06.02.2018 um 08:24 schrieb Michael Krüger: > > create or replace function reports.generic_query(_

Re: Trying to the behavior of a parallel query with with a change in the transaction isolation mode

2018-02-13 Thread Luis Carril
: Trying to the behavior of a parallel query with with a change in the transaction isolation mode Luis Carril wrote: > The transaction isolation level is serializable. This situation does not > normally arise, because parallel query plans are not generated when the > transaction isolat

Re: Trying to the behavior of a parallel query with with a change in the transaction isolation mode

2018-02-12 Thread Alvaro Herrera
Luis Carril wrote: > The transaction isolation level is serializable. This situation does not > normally arise, because parallel query plans are not generated when the > transaction isolation level is serializable. However, it can happen if the > transaction isolation level i

Trying to the behavior of a parallel query with with a change in the transaction isolation mode

2018-02-12 Thread Luis Carril
Hi all, I am trying to verify if during a transaction a parallel plan ca be generated but later only a sequential one is executed. The documentation says the following (in https://www.postgresql.org/docs/9.6/static/when-can-parallel-query-be-used.html): --- Even when parallel

Re: Parallel Query - Can it be used within functions?

2018-02-05 Thread Andreas Kretschmer
Hi, Am 06.02.2018 um 08:24 schrieb Michael Krüger: create or replace function reports.generic_query(_sql text)   RETURNS SETOF record   LANGUAGE 'plpgsql'   PARALLEL SAFE   COST 100 there is an other parameter, parallel_setup_cost, with default = 1000. I think, you should set this parameter

Parallel Query - Can it be used within functions?

2018-02-05 Thread Michael Krüger
Dear community, I need a bit of advice on parallel query execution. I have a table with roughly 2 million rows in it. These rows are distributed over a set of IDs. Therefore I can group my rows based on the ID set. If I query the table directly like this: select mediatrunkid,count(*)::numeric

Re: Parallel Query

2018-01-11 Thread Rafia Sabih
n be started by a single Gather or Gather > Merge node. > > I am not able to understand gather and gather merge node. > > With parallel query in picture, there are two new types of nodes introduced in postgresql 10 viz, Gather node and other is Gather-Merge node. Now, if seq-sca

Parallel Query

2018-01-10 Thread Krithika Venkatesh
Hi All, I was reading about parallel queries in postgresql 10. I came across the property max_parallel_workers_per_gather. It sets the maximum number of workers that can be started by a single Gather or Gather Merge node. I am not able to understand gather and gather merge node. What is the dif