Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1X2KIg-00079e-Cc for pgsql-performance@arkaria.postgresql.org; Wed, 02 Jul 2014 13:10:14 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1X2KIf-00072t-Ro for pgsql-performance@arkaria.postgresql.org; Wed, 02 Jul 2014 13:10:13 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1X2KIe-00070V-NR for pgsql-performance@postgresql.org; Wed, 02 Jul 2014 13:10:12 +0000 Received: from plane.gmane.org ([80.91.229.3]) by makus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1X2KIb-00047M-Al for pgsql-performance@postgresql.org; Wed, 02 Jul 2014 13:10:10 +0000 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X2KIX-0007up-6D for pgsql-performance@postgresql.org; Wed, 02 Jul 2014 15:10:05 +0200 Received: from 209.92.192.148 ([209.92.192.148]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 02 Jul 2014 15:10:05 +0200 Received: from droberge by 209.92.192.148 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 02 Jul 2014 15:10:05 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-performance@postgresql.org From: Dave Roberge Subject: Hash Join node sometimes slow Date: Wed, 2 Jul 2014 13:01:47 +0000 (UTC) Lines: 41 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 209.92.192.148 (Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36) X-Pg-Spam-Score: 2.2 (++) 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 Hi, I'm in the process of attempting to tune some slow queries. I came across a scenario where I'm not entirely sure how I might figure out why a node is taking awhile to process. I'm not concerned with the query itself, we are working to figure out how we can make it faster. But I was hoping someone might be able to provide some insight into why a hash join is sometimes slow. For example, running explain (analyze, buffers) with the query, 4/5 times we will see the following: -> Hash Join (cost=16385.76..103974.09 rows=523954 width=64) (actual time=532.634..4018.678 rows=258648 loops=1) Hash Cond: (p.a = c.c) Buffers: shared hit=4 read=29147, temp read=12943 written=12923 -> Seq Scan on p (cost=0.00..38496.88 rows=1503188 width=60) (actual time=0.013..1388.205 rows=1503188 loops=1) Buffers: shared hit=1 read=23464 -> Hash (cost=15382.47..15382.47 rows=57703 width=12) (actual time=527.237..527.237 rows=57789 loops=1) Buckets: 4096 Batches: 4 Memory Usage: 632kB Buffers: shared hit=3 read=5683, temp read=617 written=771 The other times, we will see something like this: -> Hash Join (cost=16385.76..103974.09 rows=523954 width=64) (actual time=587.277..15208.621 rows=258648 loops=1) Hash Cond: (p.a = c.c) Buffers: shared hit=26 read=29125, temp read=12943 written=12923 -> Seq Scan on p (cost=0.00..38496.88 rows=1503188 width=60) (actual time=0.013..1525.608 rows=1503188 loops=1) Buffers: shared hit=22 read=23443 -> Hash (cost=15382.47..15382.47 rows=57703 width=12) (actual time=581.638..581.638 rows=57789 loops=1) Buckets: 4096 Batches: 4 Memory Usage: 632kB Buffers: shared hit=4 read=5682, temp read=617 written=771 Does anyone have ideas on what might be causing the difference in timing for the hash join node? Thanks -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance