Re: FETCH FIRST clause PERCENT option

Поиск
Список
Период
Сортировка
От Surafel Temesgen
Тема Re: FETCH FIRST clause PERCENT option
Дата
Msg-id CALAY4q9VwmaGLHAHAjiGYedgrjvamM_4QCstpk6711vky2DVSQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: FETCH FIRST clause PERCENT option  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Ответы Re: FETCH FIRST clause PERCENT option  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Список pgsql-hackers


On Thu, Jan 3, 2019 at 4:51 PM Tomas Vondra <tomas.vondra@2ndquadrant.com> wrote:

On 1/3/19 1:00 PM, Surafel Temesgen wrote:
> Hi
>
> On Tue, Jan 1, 2019 at 10:08 PM Tomas Vondra
> <tomas.vondra@2ndquadrant.com <mailto:tomas.vondra@2ndquadrant.com>> wrote:

>     The execution part of the patch seems to be working correctly, but I
>     think there's an improvement - we don't need to execute the outer plan
>     to completion before emitting the first row. For example, let's say the
>     outer plan produces 10000 rows in total and we're supposed to return the
>     first 1% of those rows. We can emit the first row after fetching the
>     first 100 rows, we don't have to wait for fetching all 10k rows.
>
>
> but total rows count is not given how can we determine safe to return row
>

But you know how many rows were fetched from the outer plan, and this
number only grows grows. So the number of rows returned by FETCH FIRST
... PERCENT also only grows. For example with 10% of rows, you know that
once you reach 100 rows you should emit ~10 rows, with 200 rows you know
you should emit ~20 rows, etc. So you may track how many rows we're
supposed to return / returned so far, and emit them early.




yes that is clear but i don't find it easy to put that in formula. may be someone with good mathematics will help

regards
Surafel
 

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Alsup
Дата:
Сообщение: Re: SQL/JSON: functions
Следующее
От: Surafel Temesgen
Дата:
Сообщение: Re: FETCH FIRST clause PERCENT option