X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7622ED1B488 for ; Thu, 29 Jul 2004 13:09:04 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32828-09 for ; Thu, 29 Jul 2004 16:09:01 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 3B31ED1B462 for ; Thu, 29 Jul 2004 13:08:58 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 755433531F; Thu, 29 Jul 2004 09:08:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 7393A3531D; Thu, 29 Jul 2004 09:08:55 -0700 (PDT) Date: Thu, 29 Jul 2004 09:08:55 -0700 (PDT) From: Stephan Szabo To: Stan Bielski Cc: pgsql-performance@postgresql.org Subject: Re: Optimizer refuses to hash join In-Reply-To: Message-ID: <20040729090450.D97947@megazone.bigpanda.com> References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/224 X-Sequence-Number: 7615 On Tue, 27 Jul 2004, Stan Bielski wrote: > I having a great deal of difficulty getting postgres to do a hash join. > Even if I disable nestloop and mergejoin in postgres.conf, the optimizer > still refuses to select hash join. This behavior is killing my > performance. > > Postgres version is 7.3.2 and relevant tables are vacuum analyzed. > > Here's an overview of what I'm doing: > > I have one table of network logs ordered by time values. The other table > is a set of hosts (approximately 60) that are infected by a worm. I want > to do this query on the dataset: > > standb=# explain SELECT count (allflow_tv_sobig.tv_s) FROM > allflow_tv_sobig, blaster_set WHERE allflow_tv_sobig.src = > blaster_set.label AND allflow_tv_sobig.tv_s >= 1060101118::bigint and > allflow_tv_sobig.tv_s < 1060187518::bigint; Can you send explain analyze results for the normal case and the nested loop case? It's generally more useful than plain explain. I'd also wonder if blaster_set.label is unique such that you might be able to write the condition as an exists clause and if that's better. If you were running 7.4, I'd suggest IN, but that'll certainly be painful in 7.3.