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-25T14:46:43Z
Lists: pgsql-hackers
Attachments
- push-down-bound-to-workers-2.patch (text/x-diff) patch
Robert Haas <robertmhaas@gmail.com> writes: > I'm inclined to commit both of these after a little more testing and > self-review, but let me know if anyone else wants to review first. Attached is an updated version of the first patch, which I rebased over 3f4c7917b, improved a bunch of the comments for, and fixed a couple of obvious typos in. However, when I went to test it, it blew up real good: regression=# set parallel_setup_cost=0; SET regression=# set parallel_tuple_cost=0; SET regression=# set min_parallel_table_scan_size=0; SET regression=# set max_parallel_workers_per_gather=4; SET regression=# explain analyze select * from tenk1 order by fivethous limit 4; ERROR: retrieved too many tuples in a bounded sort CONTEXT: parallel worker The cause is obvious: GatherMerge doesn't know about the contract that it's not supposed to pull more than tuples_needed rows from an input after promising not to do so. I am not convinced that it's worth adding the logic that would be needed to make that happen, so my inclination is to abandon this patch. But here it is if you want to push further. 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