Re: Parallel queries in single transaction

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Paul Muntyanu <pmuntyanu(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Parallel queries in single transaction
Date: 2018-07-16 09:44:50
Message-ID: 7219b37d-37c1-5843-0465-9df7ab8cef2e@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 07/16/2018 09:45 AM, Paul Muntyanu wrote:
> Hello,
>
>    I am working with data warehouse based on postgresql and would like
> to propose a feature. The idea is to give control and ability for
> developer to execute queries in parallel within single transaction.
> Usual flow is next: START_TRANSACTION -> QUERY1 -> QUERY2 -> QUERY3 ->
> END_TRANSACTION. However sometimes QUERY1 and QUERY2 are independent and
> can be executed in parallel mode. E.g.: START_TRANSACTION ->
> DEFINE_QUERY1(no execution) -> DEFINE_QUERY2(no_execution) ->
> EXECUTE_QUERY1_AND_QUERY2(in parallel) -> QUERY3 -> END
>
> Of course QUERY1 and QUERY2 can be dependent and then this would not
> work, but sometimes it is useful, especially when you have bound to e.g.
> CPU and query stuck.

I'm struggling to understand what would be the possible benefits. Either
the queries are CPU-bound or stuck (e.g. waiting for I/O), they can't be
both at the same time. If a query is stuck, running it concurrently is
pointless. If they are CPU-bound, we can run them in parallel (which
should produce the results faster).

I'd even dare to say that running the queries concurrently can easily
hinder performance, because the queries will compete for parallel
workers, preventing some of them from running in parallel mode.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul Muntyanu 2018-07-16 10:03:08 Re: Parallel queries in single transaction
Previous Message Tomas Vondra 2018-07-16 09:26:18 Re: patch to allow disable of WAL recycling