Re: FETCH FIRST clause PERCENT option - Mailing list pgsql-hackers

From Andres Freund
Subject Re: FETCH FIRST clause PERCENT option
Date
Msg-id 20180921002920.wsufejsz4h3422lz@alap3.anarazel.de
Whole thread Raw
In response to Re: FETCH FIRST clause PERCENT option  (Mark Dilger <hornschnorter@gmail.com>)
Responses Re: FETCH FIRST clause PERCENT option  (Mark Dilger <hornschnorter@gmail.com>)
List pgsql-hackers
Hi,

On 2018-09-20 17:06:36 -0700, Mark Dilger wrote:
> I should think that spilling anything to a tuplestore would only be needed
> if the query contains an ORDER BY expression.  If you query
> 
>     FETCH FIRST 50 PERCENT * FROM foo;
> 
> you should just return every other row, discarding the rest, right?  It's
> only when an explicit ordering is given that the need to store the results
> arises.  Even with
> 
>     FETCH FIRST 50 PERCENT name FROM foo ORDER BY name;
> 
> you can return one row for every two rows that you get back from the
> sort node, reducing the maximum number you need to store at any time to
> no more than 25% of all rows.

I'm doubtful about the validity of these optimizations, particularly
around being surprising. But I think more importantly, we should focus
on the basic implementation that's needed anyway.

Greetings,

Andres Freund


pgsql-hackers by date:

Previous
From: Mark Dilger
Date:
Subject: Re: FETCH FIRST clause PERCENT option
Next
From: Andres Freund
Date:
Subject: Re: Bug fix for glibc broke freebsd build in REL_11_STABLE