Re: FETCH FIRST clause PERCENT option

From: Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp>
To: surafel3000(at)gmail(dot)com
Cc: tomas(dot)vondra(at)2ndquadrant(dot)com, vik(dot)fearing(at)2ndquadrant(dot)com, hornschnorter(at)gmail(dot)com, andres(at)anarazel(dot)de, pgsql-hackers(at)postgresql(dot)org, andrew(at)tao11(dot)riddles(dot)org(dot)uk
Subject: Re: FETCH FIRST clause PERCENT option
Date: 2019-02-28 11:49:36
Message-ID: 20190228.204936.197398551.horiguchi.kyotaro@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

At Thu, 28 Feb 2019 13:32:17 +0300, Surafel Temesgen <surafel3000(at)gmail(dot)com> wrote in <CALAY4q_TrFN2z1oQcpxCKB5diy+A7m5hhG4VOV5d1BaWpf+qqA(at)mail(dot)gmail(dot)com>
> On Sun, Feb 24, 2019 at 12:27 AM Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
> wrote:
>
> >
> > I'm sorry, I still don't understand what the supposed problem is. I
> > don't think it's all that different from what nodeMaterial.c does, for
> > example.
> >
> >
> sorry for the noise .Attache is complete patch for incremental approach

Mmm. It seems just moving
reading-all-before-return-the-first-tuple from LIMIT_INITIAL to
LIMIT_RESCAN. If I read it correctly node->conut is not correct
since it is calculated as "the percentage of the number of tuples
read *so far* excluding the offset portion.).

| while (node->position - node->offset >= node->count)
| {
| slot = ExecProcNode(outerPlan);
| (if Tupleis Null then break;)
| tuplestore_puttupleslot(node->tuple_store, slot);
| cnt = tuplestore_tuple_count(node->tuple_store);
| node->count = ceil(node->percent * cnt / 100.0);
| }

If I'm missing nothing, this seems almost same with the follows.

while ((position - offset) * percent / 100 >=
(position - offset) * percent / 100) {}

In the first place, the patch breaks nodeLimit.c and build fails.

====
- * previous time we got a different result.
+ * previous time we got a different result.In PERCENTAGE option there are
+ * no bound on the number of output tuples */
*/
====

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2019-02-28 12:11:04 Re: get_controlfile() can leak fds in the backend
Previous Message David Rowley 2019-02-28 11:26:42 Re: extension patch of CREATE OR REPLACE TRIGGER