Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-09 Thread Michał Kłeczek
> On 9 Oct 2023, at 15:04, Ashutosh Bapat wrote: > > On Mon, Oct 9, 2023 at 4:33 PM David Rowley > 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. >> > > postgr

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-09 Thread Ashutosh Bapat
On Mon, Oct 9, 2023 at 4:33 PM David Rowley wrote: > > On Mon, 9 Oct 2023 at 23:35, Ashutosh Bapat > wrote: > > > > On Mon, Oct 9, 2023 at 6:25 AM David Rowley wrote: > > > > > > However, it may also be worth you reading over [3] and the ultimate > > > reason I changed my mind on that being a go

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-09 Thread David Rowley
On Mon, 9 Oct 2023 at 23:35, Ashutosh Bapat wrote: > > On Mon, Oct 9, 2023 at 6:25 AM David Rowley wrote: > > > > However, it may also be worth you reading over [3] and the ultimate > > reason I changed my mind on that being a good idea. Pushing LIMITs > > below an Append seems quite incomplete w

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-09 Thread Ashutosh Bapat
On Mon, Oct 9, 2023 at 6:25 AM David Rowley wrote: > > However, it may also be worth you reading over [3] and the ultimate > reason I changed my mind on that being a good idea. Pushing LIMITs > below an Append seems quite incomplete when we don't yet push sorts > below Appends, which is what that

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-08 Thread Andy Fan
On Mon, Oct 9, 2023 at 8:52 AM David Rowley wrote: > On Sun, 8 Oct 2023 at 18:32, Michał Kłeczek wrote: > > On 8 Oct 2023, at 03:33, Andy Fan wrote: > >> 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

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-08 Thread David Rowley
On Sun, 8 Oct 2023 at 18:32, Michał Kłeczek wrote: > On 8 Oct 2023, at 03:33, Andy Fan wrote: >> 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. > Could you

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-07 Thread Michał Kłeczek
Thanks for the feedback. > On 8 Oct 2023, at 03:33, Andy Fan wrote: > > > > On Sun, Oct 8, 2023 at 5:04 AM Michał Kłeczek > wrote: >> Hi All, >> >> Attached is a second version of the patch. >> >> The goal is to: >> 1. Apply LIMIT as early as possible - especially

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-07 Thread Andy Fan
On Sun, Oct 8, 2023 at 5:04 AM Michał Kłeczek 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 exam

Re: Draft LIMIT pushdown to Append and MergeAppend patch

2023-10-07 Thread Michał Kłeczek
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 2. Enable LIMIT pushdown for FDW partitions. Main idea of the patch is: 1. Wrap children of Append and MergeAppend paths in LimitPaths. 2. Let F