Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1efDgU-0004mM-V7 for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jan 2018 23:45:27 +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 1efDgU-0005Rf-Eb for pgsql-bugs@arkaria.postgresql.org; Fri, 26 Jan 2018 23:45:26 +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 1efDgU-0005RV-5W for pgsql-bugs@lists.postgresql.org; Fri, 26 Jan 2018 23:45:26 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1efDgQ-0005Jz-R3 for pgsql-bugs@postgresql.org; Fri, 26 Jan 2018 23:45:24 +0000 Received: by mail-wm0-x22a.google.com with SMTP id j21so28526623wmh.1 for ; Fri, 26 Jan 2018 15:45:21 -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=QmjXXJrOTLYWiNSAjaKyu5RullhW8Dh/IQiXaJBM3ew=; b=tlKfzKbc7SQ9XuyupAq8jjUtaDfyMt9uy67KYTStfpR0CRQCMqXF69OhQh0PfnIezV m6H1a3vQttU95gGwNplkgBiQy4fJvEw34M0W2JsnvrjVEXqujXZAZrJar0HYlR2hR9Zj yWoy0yunoQaRr6EOLRssgBLi86ANX4OBJxaBXXubOlmqURBE4CVyno6FyfW4zsbcKg78 pH4Ah3/td4SW44K2hmgLHeOVgcY1CHYSF+5/cgLVfXNvO4fIEyTMpynzQeXd4PjlY9S/ N+lCMot+bxfmD8f6buF7PoRnrV9z1MzdZneCSFMk1Qbculv232oEI/45Tp2wZc/Z3cpd YYcA== 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=QmjXXJrOTLYWiNSAjaKyu5RullhW8Dh/IQiXaJBM3ew=; b=ZJbRQU+wodZwNdOqjhzKDHzh2rKc3bD/IFQLF3OYfAF/B1/CvzlwutCpd8D/fAhD4g 2fDHI5Oh1P1aGzGY1MW4dpcDPDvV4m7dpMbMzjCd77n5o1m7/ER4/i/Y5lid/U1VlvxV oirPOu17cDuEyQJ7HGij07uQWbEHVsD1WlrwBZgQLX1JM6vFOOqlUzABVgx/5vEV3lbJ lSKScQyWGaUCgQDUYaJIBlDf9DRwqSx9CoR9Ka8oPjweIL9eo0QzUjzGXjG/vQFNcMVc DDW8tub50uMS1FWtNfz//GXljLJTESFYTOupNVG02VAG8ed5ceWSV0OSqJIrDmAbrob0 Ymsw== X-Gm-Message-State: AKwxytcAxyGna9C8Bc4goZLM3T1sNKufhdzhbaegSR9W96dv56Uh/QTy cQXj5HQ8RXUrA1GMNyECP71hEOL29v0= X-Google-Smtp-Source: AH8x225ZhUNfbRMn9aB77ln/WbeWnGyBLv2rQkHr91Wk4Iue6AYt9n/0k+8MU1UqmI9uPH0VqOZ8Rw== X-Received: by 10.28.4.84 with SMTP id 81mr11429911wme.150.1517010320803; Fri, 26 Jan 2018 15:45:20 -0800 (PST) Received: from [10.137.2.17] (213.176.broadband18.iol.cz. [109.81.176.213]) by smtp.gmail.com with ESMTPSA id 5sm8322426wre.35.2018.01.26.15.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 15:45:20 -0800 (PST) Subject: Re: BUG #14932: SELECT DISTINCT val FROM table gets stuck in an infinite loop To: Tom Lane Cc: "Todd A. Cook" , pgsql-bugs@postgresql.org, Andres Freund References: <20171127185700.1470.20362@wrigleys.postgresql.org> <5d764e7f-269f-7f6d-3885-88295dc9e03d@blackducksoftware.com> <12511.1517008946@sss.pgh.pa.us> From: Tomas Vondra Message-ID: <43825a04-d36c-2632-91fd-332e0fa2bd72@2ndquadrant.com> Date: Sat, 27 Jan 2018 00:45:18 +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: <12511.1517008946@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 01/27/2018 12:22 AM, Tom Lane wrote: > Tomas Vondra writes: >> I suspect you're right the hash is biased to lohalf bits, as you wrote >> in the 19/12 message. > > I don't see any bias in what it's doing, which is basically xoring the > two halves and hashing the result. It's possible though that Todd's > data set contains values in which corresponding bits of the high and > low halves are correlated somehow, in which case the xor would produce > a lot of cancellation and a relatively small number of distinct outputs. > Hmm, that makes more sense than what I wrote. Probably time to get some sleep or drink more coffee, I guess. BTW what do you think about the fact that we only really generate ~63% of the possible hash values (see my message from 11/12)? That seems a bit unfortunate, although not unexpected for simple hash hunction. > If we weren't bound by backwards compatibility, we could consider > changing to logic more like "if the value is within the int4 range, > apply int4hash, otherwise hash all 8 bytes normally". But I don't see > how we can change that now that hash indexes are first-class > citizens. > Yeah, I've been thinking about that too. But I think it's an issue only for pg_upgraded clusters, which may have have hash indexes (and also hash-partitioned tables). So couldn't we use new hash functions in fresh clusters and use the backwards-compatible ones in pg_upgraded ones?r regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services