Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aILQB-0008H4-CA for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Jan 2016 19:12:59 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aILQA-0004S0-En for pgsql-hackers@arkaria.postgresql.org; Sun, 10 Jan 2016 19:12:58 +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 1aILQ8-0004R3-SQ for pgsql-hackers@postgresql.org; Sun, 10 Jan 2016 19:12:57 +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.84) (envelope-from ) id 1aILQ1-0005Lf-1S for pgsql-hackers@postgresql.org; Sun, 10 Jan 2016 19:12:55 +0000 Received: by mail-wm0-x22a.google.com with SMTP id u188so191359033wmu.1 for ; Sun, 10 Jan 2016 11:12:48 -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=wsu7thVo98o0d4c9kMyraQvqUNJ33gYSR6oCvRURAK0=; b=As3KU8Ka1/dgEEu9nbP+OcHdOvLj90m2uKhkfrfHL5kv11TPbuw37di9ivU4iAIgsn ySLrwO7Gl3jzYlNLcYC2oFyaWa8Pr62fT/7pvEQzViGupXXHsK0O+OUwEmGe2fGuE5St pps1WvM+zILYp/8r60OszcXdUbx2My/nPgnj2GegjHnmqiAPgUgICPN6UoPDMPQPK1Jf BbRU4uSKxhoCNzlO/7M32cpLTvmoVTCpS3Zq7ogF/9EyEms/1L3Ym3mnnDWSLk9HzaFK Zpqzy9KuIcRHePtxTGbSoD3mk0r08U8G6mTItWCuiv09GFul0RLyjL6PYfXaGrHEgc5X c68Q== 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=wsu7thVo98o0d4c9kMyraQvqUNJ33gYSR6oCvRURAK0=; b=hd6O0xmDjQ0EcmhsUckFGv2Yh+xEF/CBYNE+uLOkhCaAwvdIaeU8LdWYozCCOqUsbQ osxl+oGBNe89aE74csokTmzDDDZd9uZ8cW/eCME/UWq6L8C1X20YY5jOFgKLpA0tCBxT F/HoRbtGJyXJTtc9vAfXE8bqZWmgqPsEqkE68/SeAHqoygVugXzOkgZS6uYHmxfv3XO7 TjDL529lQPLGfIoDIExFW+33+2gQT7CjEopH5S4DDPTP/qTzvYMVyXvCCbaR3V0TZ5nq g9iLh3auoeP2gpIrV4wcKiatdW8xOFRmb/AEueX/nOazk0QYA+ljYJeVPBdys2JtD8Is TnyQ== X-Gm-Message-State: ALoCoQk81LkuQXtvAQiUrF6PZsUVi1WE+WnTVD87GQ44+4H9tqxuKCpwLpGkT30T9HqmvE3gvbC13IdS85RWy8MhSaKLmytSoRM3GL70CKKUPEyOhk/XjuF/PpBWn5MOMSNynGC2urhYxdQlX9Wl6zdNfOEVmEUn4D0hamD2URqg474Z3RxeIsoqikkKXmWlM3P5W++ukoLCpaKzaQxeWF4n+NCCAlib2A== X-Received: by 10.194.92.147 with SMTP id cm19mr119610017wjb.32.1452453166435; Sun, 10 Jan 2016 11:12:46 -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 a126sm9396120wmh.0.2016.01.10.11.12.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 10 Jan 2016 11:12:45 -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: <5692AD27.6010300@2ndquadrant.com> Date: Sun, 10 Jan 2016 20:12:39 +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: 8bit 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 01:08 AM, Peter Geoghegan wrote: > On Sat, Jan 9, 2016 at 11:02 AM, Tomas Vondra > wrote: >> So, this seems to bring reasonable speedup, as long as the selectivity is >> below 50%, and the data set is sufficiently large. > > What about semijoins? Apparently they can use bloom filters > particularly effectively. Have you considered them as a special case? You mean to handle them in a special way in the code, or just to perform benchmark semijoins (and not just regular joins)? > Also, have you considered Hash join conditions with multiple > attributes as a special case? I'm thinking of cases like this: > > regression=# set enable_mergejoin = off; > SET > regression=# explain analyze select * from tenk1 o join tenk2 t on > o.twenty = t.twenty and t.hundred = o.hundred; > QUERY PLAN > ────────────────────────────────────────────────────────────────────── > Hash Join (cost=595.00..4103.00 rows=50000 width=488) (actual > time=12.086..1026.194 rows=1000000 loops=1) > Hash Cond: ((o.twenty = t.twenty) AND (o.hundred = t.hundred)) > -> Seq Scan on tenk1 o (cost=0.00..458.00 rows=10000 width=244) > (actual time=0.017..4.212 rows=10000 loops=1) > -> Hash (cost=445.00..445.00 rows=10000 width=244) (actual > time=12.023..12.023 rows=10000 loops=1) > Buckets: 16384 Batches: 1 Memory Usage: 2824kB > -> Seq Scan on tenk2 t (cost=0.00..445.00 rows=10000 > width=244) (actual time=0.006..3.453 rows=10000 loops=1) > Planning time: 0.567 ms > Execution time: 1116.094 ms > (8 rows) > > (Note that while the optimizer has a slight preference for a merge > join in this case, the plan I show here is a bit faster on my > machine). The patch I posted actually does not build bloom filter on the values directly, but on the hashvalue we already use. So it handles hashjoins with arbitrary number of attributes just fine. Or perhaps you're thinking about some special optimization that might improve such cases (I can't think of any)? 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