Re: ORDER BY pushdowns seem broken in postgres_fdw
Ronan Dunklau <ronan.dunklau@aiven.io>
From: Ronan Dunklau <ronan.dunklau@aiven.io>
To: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>,
Robert Haas <robertmhaas@gmail.com>,
Jeevan Chalke <jeevan.chalke@enterprisedb.com>,
Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: David Rowley <dgrowleyml@gmail.com>
Date: 2021-07-21T09:05:14Z
Lists: pgsql-hackers
Le mercredi 21 juillet 2021, 04:25:00 CEST David Rowley a écrit : > Here the test claims that it wants to ensure that the order by using > operator(public.<^) is not pushed down into the foreign scan. > However, unless I'm mistaken, it seems there's a completely wrong > assumption there that the planner would even attempt that. In current > master we don't add PathKeys for ORDER BY aggregates, why would that > sort get pushed down in the first place? The whole aggregate, including it's order by clause, can be pushed down so there is nothing related to pathkeys here. > > If I adjust that query to something that would have the planner set > pathkeys for, it does push the ORDER BY to the foreign server without > any consideration that the sort operator is not shippable to the > foreign server. > > Am I missing something here, or is postgres_fdw.c's > get_useful_pathkeys_for_relation() just broken? I think you're right, we need to add a check if the opfamily is shippable. I'll submit a patch for that including regression tests. Regards, -- Ronan Dunklau
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