Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aINHI-0004Xh-5k for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Jan 2016 21:11:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aINHH-0007JZ-OW for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Jan 2016 21:11:55 +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) (envelope-from ) id 1aINHH-0007JS-3X for pgsql-hackers@postgresql.org; Sun, 10 Jan 2016 21:11:55 +0000 Received: from mail-wm0-x233.google.com ([2a00:1450:400c:c09::233]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1aINHD-0007nS-HL for pgsql-hackers@postgresql.org; Sun, 10 Jan 2016 21:11:53 +0000 Received: by mail-wm0-x233.google.com with SMTP id f206so241926755wmf.0 for ; Sun, 10 Jan 2016 13:11:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-type:content-transfer-encoding; bh=GGz7VkVeczTrQ4TDAq/gnfDx0pfcNyMl1MnH6Q6wRok=; b=VA4yIoYmCeVM2DXR4HP2UmyLp3Jfm5wCAvoqFRzXmHZyW7nqUo0Ajc/a62j9WDVEj2 XZwc0M72AX9x71rmbEl8QLmP7PKB3b6SY2gv81oAkPDO0DBR+54nNdFvrp6gg4RhA9/i u/rtRcOdxlfOuWd0ceE7RFu5bvb4tpyIdoNRNRfZt3fvxIBzZQORtcRFfXZoVvt7+Vsd KDTFQKkFcfTHf/yf+8ifggVnZvSwqSTMzKNt3aixTRKuMMfSdUXXu9pId0kQF5keS56y SLe/enKucxXEYGXF7iZr9dmqxwni2HqLA9NQiUu4dVJ7sxKDHnwS8OQ2dPpyZrQijRtP L3OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-type :content-transfer-encoding; bh=GGz7VkVeczTrQ4TDAq/gnfDx0pfcNyMl1MnH6Q6wRok=; b=aDPRTfhvSCmiNm7x5bhTY4Kypzqt2PNYgvSxu666xHUMy9Poc2WYlYaN4exBMlExgV PHWMje9OANFR5OpGL6NY3+9q/swi2OlK9GffUPmpUTWJEJHMV2IpJmVGtfMUXZqK59AE QltFGy7B52oiacyqOizNUMgGEHsPnQBPy+nWkbSO4Gpsj05gHOq82SNMQpbrFW0y223M mSBiaDlE7UD25pgEJWcJx+G0sgCR2icPAlWYPJidAD4U538Uyurp7uo34rVXLILj/vfn 2IgoAHm6smPgunaJMrTBlscPV6jjBSTMfGVdFOCBhgplzTtT56VKKEuW7zGkEOlhKV2p t8qA== X-Gm-Message-State: ALoCoQkikOoGL9vonUidBLv9nJfANj3/ZylXiP23T3ChDURqLmlyJt9BfjADwgoQpBC+kLwvM67lWpfiBziZZk5HXrFWeIz/vCRa2LoBNwZufHUIK3RqE3yLEb/niuWyVdUuMUJ5xk2Bo99UAk871GthjCIb0cEfIbqLx4KdOf1CET1iGKKfMfKp4GsPwbznSSNxz1SDBky+tAiESwBh5pqsdohHK8rMPw== X-Received: by 10.28.51.141 with SMTP id z135mr9505568wmz.85.1452460309890; Sun, 10 Jan 2016 13:11:49 -0800 (PST) Received: from [10.137.1.13] (ip-78-45-216-26.net.upcbroadband.cz. [78.45.216.26]) by smtp.gmail.com with ESMTPSA id gl10sm116444975wjb.30.2016.01.10.13.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jan 2016 13:11:48 -0800 (PST) Subject: Re: WIP: bloom filter in Hash Joins with batches To: Peter Geoghegan References: <5670946E.8070705@2ndquadrant.com> <5672DC2F.20205@2ndquadrant.com> <5691594B.4070209@2ndquadrant.com> Cc: Simon Riggs , PostgreSQL-development From: Tomas Vondra Message-ID: <5692C90E.9000300@2ndquadrant.com> Date: Sun, 10 Jan 2016 22:11:42 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org Hi, On 01/10/2016 05:11 AM, Peter Geoghegan wrote: > On Sat, Jan 9, 2016 at 11:02 AM, Tomas Vondra > wrote: >> Which means the "dim.r" column has 100 different values (0-99) with uniform >> distribution. So e.g. "WHERE r < 15" matches 15%. > > I think that the use of a uniform distribution to demonstrate this > patch is a bad idea, unless you want to have a conversation about the > worst case. > > Look at the use cases for bloom filters in general. They're almost > all some variation on the same theme: checking a bloom filter > inexpensively, to avoid an expensive cache miss (of some fashion). Right. > The Google Chrome web browser uses a bloom filter for malicious URLs. FWIW I don't think Chrome is using bloom filter for this purpose anymore. Chromium certainly does not (it's using PrefixSet instead). > It usually avoids consulting Google's servers about whether or not > any given URL that is visited is malicious by using the bloom filter. > This is effective in large part because the top 100 websites ranked > by popularity have a huge falloff in popularity as you go down the > list. It looks like a Zipfian distribution, and so I imagine they get > pretty far with a very small bloom filter, even though in theory the > chances of any given valid URL resulting in a cache miss is very > high. I'm not familiar with how Chrome used bloom filters, but I'd expect them to be very careful about false positives (and also false negatives, as the bloom filter can't contain all malicious URLs). My assumptions is that they've been able to make that work because they do have detailed stats about how frequently people visit those URLs, and use that when building the bloom filter. But we don't have such information in hashjoin. > > Generally, uniform distributions are rare in a non-canonical list of > things, like a hash join outer relation's attribute. Well, I'm not claiming testing uniform distribution is enough, but surely it's one of the cases we should handle just fine. The problem with non-uniform cases is that it really depends on the outer side of the join. For example let's say the hash table contains 1000 values, and the bloom filter has 1% false positive rate. But let's assume that the outer side has a value that triggers the false positive rate, and that it's actually 99% of the outer table. Suddenly, you have 99% false positive rate, rendering the bloom filter pointless. I don't think this is fixable while creating the bloom filter. All we can do is watch the bloom filter lookups and disable the bloom filter once the false positive rate reaches some threshold. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers