Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VBuIs-0007Gy-BE for pgsql-performance@arkaria.postgresql.org; Tue, 20 Aug 2013 22:21:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VBuIr-0003dW-Ld for pgsql-performance@arkaria.postgresql.org; Tue, 20 Aug 2013 22:21:29 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VBuIq-0003dP-H2 for pgsql-performance@postgresql.org; Tue, 20 Aug 2013 22:21:28 +0000 Received: from mail.gransy.com ([2001:1528:137::f1]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VBuIn-0008R4-GX for pgsql-performance@postgresql.org; Tue, 20 Aug 2013 22:21:28 +0000 Received: from antispam.gransy.com (antispam.gransy.com [77.78.104.124]) by mail.gransy.com (Postfix) with ESMTP id B5735508C5F for ; Wed, 21 Aug 2013 00:21:24 +0200 (CEST) X-Virus-Scanned: G-Hosting.cz + Station.cz + Klenot.cz + Subreg.cz amavisd-new at antispam.gransy.com Received: from mail.gransy.com ([82.208.44.189]) by antispam.gransy.com (antispam.gransy.com [77.78.104.124]) (amavisd-new, port 10024) with ESMTP id HG3PPJ19r6aU for ; Wed, 21 Aug 2013 00:21:24 +0200 (CEST) Received: by mail.gransy.com (Postfix, from userid 5000) id 6682F508C6A; Wed, 21 Aug 2013 00:21:24 +0200 (CEST) Received: from [192.168.1.237] (ip-78-45-139-138.net.upcbroadband.cz [78.45.139.138]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.gransy.com (Postfix) with ESMTPSA id 372F4508C5F for ; Wed, 21 Aug 2013 00:21:24 +0200 (CEST) Message-ID: <5213EBE4.5030302@fuzzy.cz> Date: Wed, 21 Aug 2013 00:21:24 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: queries with DISTINCT / GROUP BY giving different plans References: <3a56c4d2c0b2daa11a625c2983823901.squirrel@sq.gransy.com> <11586.1376505314@sss.pgh.pa.us> <520E7F33.7010305@fuzzy.cz> <7059.1377015896@sss.pgh.pa.us> <5213ADB1.3040807@fuzzy.cz> <13875.1377032529@sss.pgh.pa.us> In-Reply-To: <13875.1377032529@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 20.8.2013 23:02, Tom Lane wrote: > Tomas Vondra writes: > >> Anyway, I still don't understand why the same logic around >> hash_agg_entry_size should not apply to choose_hashed_grouping as >> well? Well, it would make it slower in this particular corner case, >> but wouldn't it be more correct? Meh, I meant it the other way around - applying the hashentrysize logic from hashed_grouping to hashed_distinct. So that both use 56B. > choose_hashed_grouping has it right, or at least more nearly right. > choose_hashed_distinct is simply failing to account for space that > will in fact be consumed. Not fixing that is not a good way to deal > with inaccurate number-of-groups estimates; if that estimate is low > rather than high, the consequences will be a lot worse than they are > here. Not quite sure how to parse this (not a native speaker here, sorry). Does that mean we want to keep it as it is now (because fixing it would cause even worse errors with low estimates)? Or do we want to fix hashed_distinct so that it behaves like hashed_grouping? Tomas -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance