Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D7F111337EF2 for ; Thu, 14 Oct 2010 05:11:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 97925-06 for ; Thu, 14 Oct 2010 08:10:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 0D9461337C57 for ; Wed, 13 Oct 2010 14:30:36 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9DHUNNQ029319; Wed, 13 Oct 2010 13:30:23 -0400 (EDT) To: Ants Aasma cc: pgsql-performance@postgresql.org Subject: Re: Bogus startup cost for WindowAgg In-reply-to: References: Comments: In-reply-to Ants Aasma message dated "Wed, 13 Oct 2010 19:57:44 +0300" Date: Wed, 13 Oct 2010 13:30:22 -0400 Message-ID: <29317.1286991022@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/224 X-Sequence-Number: 40642 Ants Aasma writes: > Seems that the window aggregate node doesn't take into account that it > has to consume the whole input before outputting the first row. Well, the reason it doesn't assume that is it's not true ;-). In this particular case it's true, but more generally you only have to read the current input partition, and often not even all of that. I'm not sure offhand how much intelligence would have to be added to make a reasonable estimate of the effects of having to read ahead of the current input row, but it's probably not trivial. We haven't spent much time at all yet on creating a realistic cost model for WindowAgg... regards, tom lane