Re: Draft LIMIT pushdown to Append and MergeAppend patch

From: Michał Kłeczek <michal(at)kleczek(dot)org>
To: Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Draft LIMIT pushdown to Append and MergeAppend patch
Date: 2023-10-08 05:27:06
Message-ID: 6235B14D-455C-4424-9B26-F39F4EB55E31@kleczek.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for the feedback.

> On 8 Oct 2023, at 03:33, Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> wrote:
>
>
>
> On Sun, Oct 8, 2023 at 5:04 AM Michał Kłeczek <michal(at)kleczek(dot)org <mailto:michal(at)kleczek(dot)org>> wrote:
>> Hi All,
>>
>> Attached is a second version of the patch.
>>
>> The goal is to:
>> 1. Apply LIMIT as early as possible - especially to apply LIMIT in partition scans
>
> For the patches for performance improvement, it is better to provide
> an example to show how much benefits we can get. As for this case,
> I'm doubtful it can work as an improvement.
>
>> 2. Enable LIMIT pushdown for FDW partitions.
>
> The same as above, some testing is helpful.

The idea came up from this e-mail thread from 2019:
https://www.postgresql.org/message-id/CAFT%2BaqL1Tt0qfYqjHH%2BshwPoW8qdFjpJ8vBR5ABoXJDUcHyN1w%40mail.gmail.com
FDW does not push down LIMIT & ORDER BY with sharding (partitions)
postgresql.org

While obviously permofmance testing is needed to confirm any real improvements
I now (after your feedback) have second thoughts if it is worth pursuing at all.

Could you elaborate a little why you think it won’t work as an improvement?
Is it because in practice LIMIT _is_ pushed down already during execution?
From what I understand postgres_fdw does indeed fetch on demand.
OTOH pushing down LIMIT is considered an improvement (as witnessed in the postgres_fdw code itself after d50d172e51)

Care to provide some more information?

Thanks,

--
Michal

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Richard Guo 2023-10-08 08:26:43 Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower
Previous Message Thomas Munro 2023-10-08 05:15:18 Re: pg_upgrade --copy-file-range