On 9 Oct 2023, at 15:04, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com> wrote:
On Mon, Oct 9, 2023 at 4:33 PM David Rowley <dgrowleyml@gmail.com> wrote:
What are there benefits if the paths are already ordered? e.g if it's
an index scan then we'll only pull the tuples we need from it.
postgres_fdw creates a path with pathkeys based on the clauses on thatrelation. There is no index involved there. Pushing down LIMIT willlimit the number of rows fetched from the foreign server and theforeign server may have opportunity to optimize query based on theLIMIT.
I would add another benefit:
opportunity to fetch everything early, buffer it and release the session.
Without limit information fdw has to keep cursors open.
—
Michal