Re: ORDER BY pushdowns seem broken in postgres_fdw
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Ronan Dunklau <ronan.dunklau@aiven.io>
Cc: pgsql-hackers@lists.postgresql.org, David Zhang <david.zhang@highgo.ca>,
Zhihong Yu <zyu@yugabyte.com>
Date: 2022-03-30T23:41:37Z
Lists: pgsql-hackers
Attachments
- v9-0001-Fix-orderby-handling-in-postgres_fdw.patch (text/x-diff) patch v9-0001
Ronan Dunklau <ronan.dunklau@aiven.io> writes: > [ v8-0001-Fix-orderby-handling-in-postgres_fdw.patch ] I looked through this patch. It's going in the right direction, but I have a couple of nitpicks: 1. There are still some more places that aren't checking shippability of the relevant opfamily. 2. The existing usage of find_em_expr_for_rel is fundamentally broken, because that function will seize on the first EC member that is from the given rel, whether it's shippable or not. There might be another one later that is shippable, so this is just the wrong API. It's not like this function gives us any useful isolation from the details of ECs, because postgres_fdw is already looking into those elsewhere, notably in find_em_expr_for_input_target --- which has the same order-sensitivity bug. I think that instead of doubling down on a wrong API, we should just take that out and move the logic into postgres_fdw.c. This also has the advantage of producing a patch that's much safer to backpatch, because it doesn't rely on the core backend getting updated before postgres_fdw.so is. So hacking on those two points, and doing some additional cleanup, led me to the attached v9. (In this patch, the removal of code from equivclass.c is only meant to be applied to HEAD; we have to leave the function in place in the back branches for API stability.) If no objections, I think this is committable. regards, tom lane
Commits
-
Fix postgres_fdw to check shippability of sort clauses properly.
- f3dd9fe1dd92 15.0 landed
- b9eb0412ffb8 11.16 landed
- 9f9489aa2eef 14.3 landed
- 989d3e4a2957 12.11 landed
- 79df1d20c59c 13.7 landed
- 728fc0f9a2dd 10.21 landed
-
postgres_fdw: Add ORDER BY to some remote SQL queries.
- f18c944b6137 9.6.0 cited