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

From: Luis Carril <luis(dot)carril(at)swarm64(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Trying to the behavior of a parallel query with with a change in the transaction isolation mode
Date: 2018-02-12 15:07:40
Message-ID: FRXPR01MB0070DD3B7710D14389856B0BE7F70@FRXPR01MB0070.DEUPRD01.PROD.OUTLOOK.DE
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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 query plan is generated for a particular query, there are several circumstances under which it will be impossible to execute that plan in parallel at execution time. If this occurs, the leader will execute the portion of the plan below the Gather node entirely by itself, almost as if the Gather node were not present. This will happen if any of the following conditions are met:
[...]

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 is changed to serializable after the plan is generated and before it is executed.

---

I have tried the following:

BEGIN;
SET TRANSACTION ISOLATION LEVEL READ COMMITTED, READ ONLY;
EXPLAIN (COSTS OFF) SELECT avg(a) FROM parallel_big;
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ ONLY;
EXPLAIN ANALYZE SELECT avg(a) FROM parallel_big;
COMMIT;

But complains that after the first SELECT (even if it is in an EXPLAIN) the isolation level cannot be changed, so the transaction is aborted and the SELECT is never executed (even sequentially).

Is there any way to test the possible behavior described in the documentation?

Thanks you very much

Luis M Carril

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2018-02-12 15:19:52 Re: Trying to the behavior of a parallel query with with a change in the transaction isolation mode
Previous Message Tom Lane 2018-02-12 14:09:18 Re: New Copy Formats - avro/orc/parquet