Re: fix cost subqueryscan wrong parallel cost

Justin Pryzby <pryzby@telsasoft.com>

From: Justin Pryzby <pryzby@telsasoft.com>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>, bucoo@sohu.com, pgsql-hackers@postgresql.org, Tomas Vondra <tomas.vondra@postgresql.org>, Dmitry Dolgov <9erthalion6@gmail.com>
Date: 2022-04-15T10:10:59Z
Lists: pgsql-hackers
On Fri, Apr 15, 2022 at 05:16:44PM +0800, Richard Guo wrote:
> Not related to this topic but I noticed another problem from the plan.
> Note the first Sort node which is to unique-ify the result of the UNION.
> Why cannot we re-arrange the sort keys from (a, b, c) to (a, c, b) so
> that we can avoid the second Sort node?

I don't know, but it's possible there's a solution related to commit db0d67db2
"Optimize order of GROUP BY keys" - DISTINCT is the same as GROUP BY k1, ...,
kN.  I guess UNION [DISTINCT] should learn to use GROUP BY rather than
DISTINCT?

-- 
Justin



Commits

  1. Fix rowcount estimate for SubqueryScan that's under a Gather.

  2. Optimize order of GROUP BY keys