Re: [PATCH] Push limit to sort through a subquery
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Douglas Doole <dougdoole@gmail.com>,
Konstantin Knizhnik <k.knizhnik@postgrespro.ru>,
"pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-08-25T15:15:02Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> writes: > However, there's another opportunity for optimization here, which is > the Limit -> Gather -> Anything case. A worker which has itself > generated enough tuples to fill the limit can certainly stop working, > but right now it doesn't know that. The patch I posted before didn't > think about that case, but it seems to require only trivial > modifications. Ah, good point. > I was going to post an updated patch trying to > address that, but I see that you've already posted something, so I'll > go have a look at that instead. The problem I exhibited with the updated patch could probably be resolved if the top level logic in a parallel worker knows about tuples_needed and doesn't try to pull more than that from its subplan. So what you're describing isn't just an additional optimization, it's necessary to make this work at all. regards, tom lane
Commits
-
Propagate sort instrumentation from workers back to leader.
- bf11e7ee2e36 11.0 landed
-
Push tuple limits through Gather and Gather Merge.
- 3452dc5240da 11.0 landed
-
Code review for pushing LIMIT through subqueries.
- 3f4c7917b3bc 11.0 landed
-
Make new regression test case parallel-safe, and improve its output.
- 1177ab1dabf7 11.0 landed
-
Push limit through subqueries to underlying sort, where possible.
- 1f6d515a67ec 11.0 landed
-
Move targetlist SRF handling from expression evaluation to new executor node.
- 69f4b9c85f16 10.0 cited