From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jim Finnerty <jfinnert@amazon.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Parallel append plan instability/randomness
Date: Mon, 08 Jan 2018 11:42:02 -0500
Message-ID: <2171.1515429722@sss.pgh.pa.us> (raw)
In-Reply-To: <1515428895102-0.post@n3.nabble.com>
References: <7752.1515284083@sss.pgh.pa.us>
<CAA4eK1LegxN9of0sydNM5n4up=7oCj=-E94edKDOsYFKyb1R0Q@mail.gmail.com>
<CAJ3gD9cT-u3xjAh0vkZX0wknZkWFp8sgOuWgDcRn68vy-j-wHg@mail.gmail.com>
<7400.1515390981@sss.pgh.pa.us>
<CAA4eK1JHbp2uEvmBVv7JRdCFznG9zWVy6aBB0-8arxZm4P-4hg@mail.gmail.com>
<CAJ3gD9cSKj-OioojVOf3_QTB8gK=dqU1JGYEjW1WXbLVxuAeXA@mail.gmail.com>
<CAA4eK1Kxpw4_UXpT0NUWF7zY6_kLxTU9Km9Ebfhc4No3kr40NQ@mail.gmail.com>
<1515428895102-0.post@n3.nabble.com>
Jim Finnerty <jfinnert@amazon.com> writes:
> Ordering the plan output elements by estimated cost will cause spurious plan
> changes to be reported after table cardinalities change. Can we choose an
> explain output order that is stable to changes in cardinality, please?
I found the code that's doing this, in create_append_path, and it says:
* For parallel append, non-partial paths are sorted by descending total
* costs. That way, the total time to finish all non-partial paths is
* minimized. Also, the partial paths are sorted by descending startup
* costs. There may be some paths that require to do startup work by a
* single worker. In such case, it's better for workers to choose the
* expensive ones first, whereas the leader should choose the cheapest
* startup plan.
There's some merit in that argument, although I'm not sure how much.
It's certainly pointless to sort that way if the expected number of
workers is >= the number of subpaths. More generally, I wonder if
it wouldn't be better to implement this behavior at runtime rather
than plan time. Something along the line of "workers choose the
highest-cost remaining subplan, but leader chooses the lowest-cost one".
regards, tom lane
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, jfinnert@amazon.com
Subject: Re: Parallel append plan instability/randomness
In-Reply-To: <2171.1515429722@sss.pgh.pa.us>
References: <7752.1515284083@sss.pgh.pa.us> <CAA4eK1LegxN9of0sydNM5n4up=7oCj=-E94edKDOsYFKyb1R0Q@mail.gmail.com> <CAJ3gD9cT-u3xjAh0vkZX0wknZkWFp8sgOuWgDcRn68vy-j-wHg@mail.gmail.com> <7400.1515390981@sss.pgh.pa.us> <CAA4eK1JHbp2uEvmBVv7JRdCFznG9zWVy6aBB0-8arxZm4P-4hg@mail.gmail.com> <CAJ3gD9cSKj-OioojVOf3_QTB8gK=dqU1JGYEjW1WXbLVxuAeXA@mail.gmail.com> <CAA4eK1Kxpw4_UXpT0NUWF7zY6_kLxTU9Km9Ebfhc4No3kr40NQ@mail.gmail.com> <1515428895102-0.post@n3.nabble.com> <2171.1515429722@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