pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@2ndquadrant.com>
To: Luís Roberto Weck <luisroberto@siscobra.com.br>
Cc: pgsql-performance@lists.postgresql.org
Subject: Re: Parallel Query
Date: Wed, 13 Nov 2019 21:47:37 +0100
Message-ID: <20191113204737.l6uny3qdwl6a4u7m@development> (raw)
In-Reply-To: <732b7303-8b60-2f33-7f00-3b0cd70a7c5b@siscobra.com.br>
References: <732b7303-8b60-2f33-7f00-3b0cd70a7c5b@siscobra.com.br>

On Wed, Nov 13, 2019 at 05:16:44PM -0300, Luís Roberto Weck wrote:
>Hi!
>
>Is there a reason query 3 can't use parallel workers? Using q1 and q2 
>they seem very similar but can use up to 4 workers to run faster:
>
>q1: https://pastebin.com/ufkbSmfB
>q2: https://pastebin.com/Yt32zRNX
>q3: https://pastebin.com/dqh7yKPb
>
>The sort node on q3 takes almost 12 seconds, making the query run on 
>68  if I had set enough work_mem to make it all in memory.
>

Most likely because it'd be actually slower. The trouble is the
aggregation does not actually reduce the cardinality, or at least the
planner does not expect that - the Sort and GroupAggregate are expected
to produce 3454539 rows. The last step of the aggregation has to receive
and merge data from all workers, which is not exactly free, and if there
is no reduction of cardinality it's likely cheaper to just do everything
in a single process serially.

How does the explain analyze output look like without the HAVING clause?

Try setting parallel_setup_cost and parallel_tuple_cost to 0. That might
trigger parallel query.

regards

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





view thread (9+ messages)  latest in thread

Message-ID: <20191113204737.l6uny3qdwl6a4u7m@development>
Permalink:  ../20191113204737.l6uny3qdwl6a4u7m@development/
Also on:    postgresql.org/message-id/20191113204737.l6uny3qdwl6a4u7m@development

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: tomas.vondra@2ndquadrant.com, luisroberto@siscobra.com.br, pgsql-performance@lists.postgresql.org
  Subject: Re: Parallel Query
  In-Reply-To: <20191113204737.l6uny3qdwl6a4u7m@development>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox