Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A456D1CC11C for ; Thu, 28 Jun 2012 23:17:57 -0300 (ADT) Received: from tama500.ecl.ntt.co.jp ([129.60.39.148]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1SkQmO-0004iZ-22 for pgsql-hackers@postgresql.org; Fri, 29 Jun 2012 02:17:56 +0000 Received: from mfs5.rdh.ecl.ntt.co.jp (mfs5.rdh.ecl.ntt.co.jp [129.60.39.144]) by tama500.ecl.ntt.co.jp (8.14.5/8.14.5) with ESMTP id q5T2HTM3018067; Fri, 29 Jun 2012 11:17:29 +0900 (JST) Received: from mfs5.rdh.ecl.ntt.co.jp (localhost.localdomain [127.0.0.1]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 2AE01E00D4; Fri, 29 Jun 2012 11:17:29 +0900 (JST) Received: from dmailsv1.y.ecl.ntt.co.jp (dmailsv1.y.ecl.ntt.co.jp [129.60.53.14]) by mfs5.rdh.ecl.ntt.co.jp (Postfix) with ESMTP id 1DDBBE00D3; Fri, 29 Jun 2012 11:17:29 +0900 (JST) Received: from mailsv11.y.ecl.ntt.co.jp by dmailsv1.y.ecl.ntt.co.jp (8.14.5/dmailsv1-2.1) with ESMTP id q5T2HShx016590; Fri, 29 Jun 2012 11:17:28 +0900 (JST) Received: from localhost by mailsv11.y.ecl.ntt.co.jp (8.14.5/Lab-1.9) with ESMTP id q5T2HS44020731; Fri, 29 Jun 2012 11:17:28 +0900 (JST) From: "Etsuro Fujita" To: "'Ants Aasma'" , "'Robert Haas'" Cc: "'Jay Levitt'" , "'Tom Lane'" , "'PostgreSQL-development'" , "'Francois Deliege'" References: <22709.1332944158@sss.pgh.pa.us> <4F766454.9040909@gmail.com> <4.3.2-J.20120615194845.03a6fa20@129.60.53.11> <004a01cd4dff$bffd9a40$3ff8cec0$@lab.ntt.co.jp> In-Reply-To: Subject: Re: [PATCH] Lazy hashaggregate when no aggregation is needed Date: Fri, 29 Jun 2012 11:22:15 +0900 Message-ID: <00aa01cd559d$ffb32790$ff1976b0$@lab.ntt.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFW5RmpuYBQ1Q1EBonax2VVtvN1QQHJ2D4OAp/TGtACUg7+gAJCiNmTAtG+D6UBAUClRQI2ULBxA0s/DkEB62i7xQHRJw9Wl0z2dHA= Content-Language: ja X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/1774 X-Sequence-Number: 210614 Hi Ants, > -----Original Message----- > From: Ants Aasma [mailto:ants@cybertec.at] > Sent: Wednesday, June 27, 2012 9:23 PM > To: Robert Haas > Cc: Etsuro Fujita; Jay Levitt; Tom Lane; PostgreSQL-development; = Francois > Deliege > Subject: Re: [HACKERS] [PATCH] Lazy hashaggregate when no aggregation = is needed >=20 > Sorry about the delay in answering. I have been swamped with non-PG > related things lately. >=20 > On Tue, Jun 26, 2012 at 11:08 PM, Robert Haas = wrote: > > On Fri, Jun 22, 2012 at 10:12 AM, Robert Haas = wrote: > >> On Tue, Jun 19, 2012 at 5:41 AM, Etsuro Fujita > >> wrote: > >>>> I'm confused by this remark, because surely the query planner = does it this > >>>> way only if there's no LIMIT. =A0When there is a LIMIT, we choose = based on > >>>> the startup cost plus the estimated fraction of the total cost we = expect > >>>> to pay based on dividing the LIMIT by the overall row count = estimate. =A0Or > >>>> is this not what you're talking about? >=20 > My reasoning was that query_planner returns the cheapest-total path > and cheapest fractional presorted (by the aggregation pathkeys). When > evaluating hash-aggregates with this patch these two are indeed > compared considering the esimated fraction of the total cost, but this > might miss cheapest fractional unordered path for lazy hashaggregates. >=20 > Reviewing the code now I discovered this path could be picked out from > the pathlist, just like it is done by > get_cheapest_fractional_path_for_pathkeys when pathkeys is nil. This > would need to be returned in addition to the other two paths. To > minimize overhead, this should only be done when we possibly want to > consider lazy hash-aggregation (there is a group clause with no > aggregates and grouping is hashable) But this is starting to get > pretty crufty considering that there doesn't seem to be any really > compelling usecases for this. >=20 > > Ants, do you intend to update this patch for this CommitFest? =A0Or = at > > all? =A0It seems nobody's too excited about this, so I'm not sure > > whether it makes sense for you to put more work on it. =A0But please > > advise as to your plans. >=20 > If anyone thinks that this patch might be worth considering, then I'm > prepared to do minor cleanup this CF (I saw some possibly unnecessary > cruft in agg_fill_hash_and_retrieve). On the other hand, if you think > the use case is too marginal to consider for inclusion then I won't > shed a tear if this gets rejected. For me this was mostly a learning > experience for poking around in the planner. Honestly, I'm not sure that it's worth including this, considering the = use case... Thanks, Best regards, Etsuro Fujita > Ants Aasma > -- > Cybertec Sch=F6nig & Sch=F6nig GmbH > Gr=F6hrm=FChlgasse 26 > A-2700 Wiener Neustadt > Web: http://www.postgresql-support.de >=20