pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Maxim Boguk <maxim.boguk@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #18588: Cannot force/let database use parallel execution in simple case.
Date: Thu, 22 Aug 2024 16:42:03 -0400
Message-ID: <2073208.1724359323@sss.pgh.pa.us> (raw)
In-Reply-To: <2059550.1724353316@sss.pgh.pa.us>
References: <18588-204730f9394441a8@postgresql.org>
	<CAApHDvqGgO7c8N0kq5H4jZ0NZe=NGZDo4VVF5Fi5CVdJNbvStg@mail.gmail.com>
	<CAK-MWwTqDRerxrpaN8Xb25DqDGBw1UT+YSkfp4QN-MgOH97c+Q@mail.gmail.com>
	<CAK-MWwS_ZAsaGrz0byqCO38NNrNqPkNt1ww1dorHz_wiaFbWvw@mail.gmail.com>
	<2059550.1724353316@sss.pgh.pa.us>

I wrote:
> Hmm, you can see both behaviors on the small version of t1, just by
> varying the comparison constant in the WHERE clause.  For me, it'll
> use only one worker with "where a<1", and not parallelize at all
> with "where a<0".  It looks like it's deciding that it's not worth
> starting workers when too few rows are expected to be returned.  That
> would be unsurprising with a normal setting of parallel_setup_cost,
> but it does seem odd with parallel_setup_cost=0.

Ah, I traced through it, and here's what's happening: at small enough
estimated rowcounts, the parallel and non-parallel plans have fuzzily
the same cost (parallel is a shade cheaper, but only a shade).
Their other properties such as pathkeys are the same too.  So we get
to the tie-breaking logic in add_path, and what breaks the tie is
the difference in parallel safety: the non-parallel plan is marked
parallel_safe and the parallel one (which by this point is a Gather)
is not.

That tie-break rule is not wrong, because preserving parallel safety
can be a good thing when we come to consider use of the path at higher
plan levels.  So I think there's nothing to see here.

			regards, tom lane





view thread (17+ messages)  latest in thread

Message-ID: <2073208.1724359323@sss.pgh.pa.us>
Permalink:  ../2073208.1724359323@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2073208.1724359323@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, maxim.boguk@gmail.com, dgrowleyml@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #18588: Cannot force/let database use parallel execution in simple case.
  In-Reply-To: <2073208.1724359323@sss.pgh.pa.us>

* 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