Re: [PATCH] Push limit to sort through a subquery
Douglas Doole <dougdoole@gmail.com>
From: Douglas Doole <dougdoole@gmail.com>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Konstantin Knizhnik <k.knizhnik@postgrespro.ru>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2017-08-24T05:51:41Z
Lists: pgsql-hackers
>
> Here's a not-really-tested draft patch for that.
>
I don't know the parallel code so I'm not going to comment on the overall
patch, but a thought on ExecSetTupleBound().
That function is getting a number of cases where we're doing recursion for
a single child (result, gather, gather-merge). Recursion for a single child
isn't particularly efficient. I know that if there's a single case of
recursion like this, compilers will frequently turn it into a loop, but I
don't know if compilers can optimize a branched case like this.
Would we be better off moving those cases into the while loop I added to
avoid the recursion? So we'd end up with something like:
while ()
{
if subquery
else if result
else if gather
else if gather merge
}
if sort
else if merge append
And a nit from my original fix now that I've looked at the pg10 code more.
The two casts I added (to SubqueryScanState and Node) should probably be
changed to castNode() calls.
- Doug
Salesforce
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