Re: fix cost subqueryscan wrong parallel cost
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Guo <guofenglinux@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>,
"David G. Johnston" <david.g.johnston@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2022-04-29T14:02:18Z
Lists: pgsql-hackers
Richard Guo <guofenglinux@gmail.com> writes: > Currently subquery scan is using rel->rows (if no parameterization), > which I believe is not correct. That's not the size the subquery scan > node in each worker needs to handle, as the rows have been divided > across workers by the parallel-aware node. Really? Maybe I misunderstand the case under consideration, but what I think will be happening is that each worker will re-execute the pushed-down subquery in full. Otherwise it can't compute the correct answer. What gets divided across the set of workers is the total *number of executions* of the subquery, which should be independent of the number of workers, so that the cost is (more or less) the same as the non-parallel case. At least that's true for a standard correlated subplan, which is normally run again for each row processed by the parent node. For hashed subplans and initplans, what would have been "execute once" semantics becomes "execute once per worker", creating a strict cost disadvantage for parallelization. I don't know whether the current costing model accounts for that. But if it does that wrong, arbitrarily altering the number of rows won't make it better. regards, tom lane
Commits
-
Fix rowcount estimate for SubqueryScan that's under a Gather.
- c40ba5f318f9 15.0 landed
-
Optimize order of GROUP BY keys
- db0d67db2401 15.0 cited