Re: Count of records in a row

From: Robert James <srobertjames(at)gmail(dot)com>
To: Rémi Cura <remi(dot)cura(at)gmail(dot)com>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, Hubert Lubaczewski <depesz(at)depesz(dot)com>, Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Count of records in a row
Date: 2013-10-22 23:01:14
Message-ID: CAGYyBgirx96x_wt5X44X5=2yRQpsXoMB=Q1s5Z-n-SxyZESn1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Wow, this is an excellent discussion - and I must admit, a bit beyond
my abilities. Is there a consensus as to the best approach to adopt?
Is Elliot's the best?

On 10/22/13, Rémi Cura <remi(dot)cura(at)gmail(dot)com> wrote:
> OK,
> just out of pure curiosity,
> is it always the case or is it due to this particular aggregate?
>
> Cheers,
> Rémi-C
>
>
> 2013/10/22 Merlin Moncure <mmoncure(at)gmail(dot)com>
>
>> On Tue, Oct 22, 2013 at 9:43 AM, Rémi Cura <remi(dot)cura(at)gmail(dot)com> wrote:
>> > Thanks again for the precision !
>> >
>> > I still don't understand perfectly. We call the aggregate n times, and
>> each
>> > time we compute the aggregate, using (potentially) n rows, thus
>> > becoming
>> (at
>> > most) O(n*n).
>> >
>> > With a standard loop, I loop n times, and each times I only need the
>> current
>> > row plus the previous row which I put in memory, thus O(n).
>>
>> For posterity, the above is incorrect. Since the aggregate is ordered
>> through the window function, it gets executed exactly once per output
>> row. It behaves exactly like a loop. You know this because there is
>> no array in the aggregate state.
>>
>> merlin
>>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message ramistuni 2013-10-22 23:10:48 Re: Upgrade from 9.1 to 9.10
Previous Message James Sewell 2013-10-22 22:41:17 Re: pg_dumpall from a script