Re: Draft LIMIT pushdown to Append and MergeAppend patch - Mailing list pgsql-hackers

From Michał Kłeczek
Subject Re: Draft LIMIT pushdown to Append and MergeAppend patch
Date
Msg-id 7D291E0E-88FB-4E54-B0E6-AF519443C58A@kleczek.org
Whole thread Raw
In response to Re: Draft LIMIT pushdown to Append and MergeAppend patch  (Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>)
List pgsql-hackers


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 that
relation. There is no index involved there. Pushing down LIMIT will
limit the number of rows fetched from the foreign server and the
foreign server may have opportunity to optimize query based on the
LIMIT.

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

pgsql-hackers by date:

Previous
From: Ashutosh Bapat
Date:
Subject: Re: Draft LIMIT pushdown to Append and MergeAppend patch
Next
From: Amul Sul
Date:
Subject: Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression