Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eg9hC-0007hn-4L for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Jan 2018 13:42:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eg9hA-000614-TG for pgsql-bugs@arkaria.postgresql.org; Mon, 29 Jan 2018 13:42:00 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eg9hA-00060r-Jq for pgsql-bugs@lists.postgresql.org; Mon, 29 Jan 2018 13:42:00 +0000 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eg9h6-0007cc-Fs for pgsql-bugs@postgresql.org; Mon, 29 Jan 2018 13:41:59 +0000 Received: by mail-wr0-x236.google.com with SMTP id 36so7248802wrh.1 for ; Mon, 29 Jan 2018 05:41:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=qXGdyUPPRB9p+Zvr8U/WAeTqvUsgTwCHPR92IQcE+b8=; b=yw8trinCRZ0XQaWWsH7ZhfmyuiU+2QtU3zjQBv8+MIQrtAqlMMh35o+gFpGnzXosEy H6NxBElnDBJPxigdTd1c0oMnnqETuuULqyF4Nqto9wjPVgq+quDWKrZ9929MXoLmsGT8 KAJ2n5rLN7HDu0ORasbpc8ilRuX8Sew/VojK+9ZN5tnCZqXZ1ui4sKyoNoeF9XHXNAYk OH+4DQV8reO6tYAHwAhEMEk+R7rHTeEpsDGLiDoz2wOT7YhXBp6YrVYhAuprm13ZVonu 0/H3C1/wWHVz0fRDBfAFTiahgDzeue2h4rDZNqvHo7onmeM1Rz/tcwnMrSHCxvIGLsaw ufsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=qXGdyUPPRB9p+Zvr8U/WAeTqvUsgTwCHPR92IQcE+b8=; b=WvWWLvKGleu/h3bpJkQTXSmcpoLFpus/Vd2mL8wHFTVziZICgo/fKix0fFCN664iw/ 9i8YOynNZq5JTsqd8z9jgqetX/CVmpZLmpdplSF0hkSA+JGZPPMemaZNPiLFaVhUCVCR hUHp+hWpYsXJTrjw4mE06GXF5YS5btbtegkgfk0MdsEdjpobtBxsSwaxZOzQ8uvvQPmQ fJRnCHiP5wxt/L0RNJnuCOcc8p+M7CTZ9xUfuXyene/d6+Vi4p6TNQJg6P7V4r1NTGPQ 6Or7ugVcZc0L9hQUfwIjiKuAIqDLt0JVB9D8On5cq8B2hPXGkOPVN2NAGumU481RGVCu CK/A== X-Gm-Message-State: AKwxytecAWCeydmdFvMmEVP7V2M2fsV+ipT81cAFnpdc6Bu+cEiCWXlo iE11dPN1xIVHwSa3kk8was4O3DYLvWXkHJ1lqZsqztt4leTu5ezu5SlMs8PwPTWtj+zyddLifIG B0/cBX2u8qN5isGzMU7VqHpIOSCQOZQv2sb3nVA/rs9diWbbjFqJii1k2NlN7N7Gb2PCjajI9+q qwLSqm X-Google-Smtp-Source: AH8x224doHCjUa0I5XyslwIW9h5vytnfYoNN1tPfqTk5zZNKY/gkaKUX6vTwy7JdpC/gnJzGtDEvdA== X-Received: by 10.223.177.150 with SMTP id q22mr2735909wra.20.1517233314229; Mon, 29 Jan 2018 05:41:54 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id r42sm5022226wrb.56.2018.01.29.05.41.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jan 2018 05:41:53 -0800 (PST) Subject: Re: BUG #14932: SELECT DISTINCT val FROM table gets stuck in an infinite loop To: Andres Freund , Tom Lane Cc: "Todd A. Cook" , Thomas Munro , PostgreSQL Bugs References: <9cd29b81-7ba1-91a2-f491-9014f4ac87e6@blackducksoftware.com> <2a76784c-06cb-46ec-35be-9895d144b839@2ndquadrant.com> <219b37b2-d740-d04a-203a-49ae422028f7@blackducksoftware.com> <1773c302-2fb1-749f-8ccc-62b23617c5ac@blackducksoftware.com> <25629.1512580464@sss.pgh.pa.us> <20171206171923.dg7phzfh7nb4lou3@alap3.anarazel.de> <7de4b2d6-b119-7d15-04d8-4c0fcb29cbc3@2ndquadrant.com> <20180126234537.dyu6jwnqz7snpq7n@alap3.anarazel.de> <14184.1517010515@sss.pgh.pa.us> <20180129010213.rt3nu73ilff756f6@alap3.anarazel.de> From: Tomas Vondra Message-ID: <3971fa24-285b-1c57-db95-b15c513162c1@2ndquadrant.com> Date: Mon, 29 Jan 2018 14:41:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20180129010213.rt3nu73ilff756f6@alap3.anarazel.de> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01/29/2018 02:02 AM, Andres Freund wrote: > On 2018-01-26 18:48:35 -0500, Tom Lane wrote: >> Andres Freund writes: >>> On 2017-12-10 23:09:42 +0100, Tomas Vondra wrote: >>>> FWIW I do agree the data sets shared in this thread are pretty extreme >>>> and it doesn't make much sense to slow the regular cases. I'll be >>>> perfectly happy if we stop the OOM, making those cases fast is a bonus. >> >>> Yea, agreed on that. I'm kinda inclined to go for stop-growing in 10, >>> and so something better in 11. And then later possibly backpatch if >>> we've grown some confidence? >> >> +1. I'd like to see some response to this included in 10.2, and time >> grows short for that. > > Here are two patches that I think we want for 10.2, and the start of one > that I think we want for master. 0002 is needed because otherwise the > lack of extra growth leads to noticeably worse performance when filling > an underestimated a coordinator hash table from the workers - turns out > our hash combine (and most hash combines) let a lot of clustering > survive. By adding a final hashing round the bit perturbation is near > perfect. The commit messages need to be polished a bit, but other than > that I think these are reasonable fixes. Plan to push by Monday evening > at the latest. > > The third patch is a version of the random IV discussed in this > thread. I do think we want to add usage of the extended hash functions, > as prototyped by Tomas, as that actually helps to fix issues with actual > hash conflicts. But we additionally need a fallback path for types > without extended hashtables, and the random IV is a good idea > nonetheless. There's no ABI difference in my patch, so I think this is > actually something we could backpatch. But I don't think it's urgent, so > I'm not planning to do that for 10.2. The one thing that could confuse > people is that it can lead to output order changes from run to run - I > think that's actually good, nobody should rely on hashagg etc output > being stable, but it might be a bit much in a stable release? > > > In my tests this solves the worst performance issues in Todd's case, > Tomas's, Thomas's and still does ok performancwith with a TPC-H Q18 > (which showcases the underestimated worker hashtable into leader > hashtable issue). > Sounds reasonable. Do you think repeating the performance testing is necessary? Not sure when do you plan to push the changes, I may not have time for the tests until after FOSDEM. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services