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 98E9452800 for ; Mon, 8 Aug 2005 22:09:01 -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 46006-03 for ; Tue, 9 Aug 2005 01:08:50 +0000 (GMT) Received: from cassarossa.samfundet.no (cassarossa.samfundet.no [129.241.93.19]) by svr1.postgresql.org (Postfix) with ESMTP id 245B0528F6 for ; Mon, 8 Aug 2005 22:08:49 -0300 (ADT) Received: from trofast.ipv6.sesse.net ([2001:700:300:dc03:20e:cff:fe36:a766] helo=trofast.sesse.net) by cassarossa.samfundet.no with esmtp (Exim 4.50) id 1E2Ibr-00069y-Cc for pgsql-performance@postgresql.org; Tue, 09 Aug 2005 03:08:51 +0200 Received: from sesse by trofast.sesse.net with local (Exim 3.36 #1 (Debian)) id 1E2Ibq-00052V-00 for ; Tue, 09 Aug 2005 03:08:50 +0200 Date: Tue, 9 Aug 2005 03:08:50 +0200 From: "Steinar H. Gunderson" To: pgsql-performance@postgresql.org Subject: Re: Why hash join instead of nested loop? Message-ID: <20050809010850.GA18938@uio.no> Mail-Followup-To: pgsql-performance@postgresql.org References: <41b0fe890508051135712a086b@mail.gmail.com> <001801c59a0a$f4be7480$9a00a8c0@OTTO> <41b0fe8905080516164464e04f@mail.gmail.com> <15425.1123304631@sss.pgh.pa.us> <41b0fe89050808100021a2a4fc@mail.gmail.com> <10930.1123549106@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <10930.1123549106@sss.pgh.pa.us> X-Operating-System: Linux 2.6.11.8 on a i686 X-Message-Flag: Outlook? --> http://www.mozilla.org/products/thunderbird/ User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.017 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200508/72 X-Sequence-Number: 13819 On Mon, Aug 08, 2005 at 08:58:26PM -0400, Tom Lane wrote: > Hmph. There is something really strange going on here. I tried to > duplicate your problem in 7.4.*, thus: PostgreSQL 7.4.7 (Debian sarge): regression=# explain analyze select rtmessagestate.* from rtmessagestate,connection where (connection_registry_id = 40105) AND (obj1 = 73582) and id = obj2; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------- Hash Join (cost=4.83..5.91 rows=1 width=14) (actual time=0.155..0.159 rows=1 loops=1) Hash Cond: ("outer".id = "inner".obj2) -> Seq Scan on rtmessagestate (cost=0.00..1.05 rows=5 width=14) (actual time=0.003..0.006 rows=5 loops=1) -> Hash (cost=4.83..4.83 rows=1 width=4) (actual time=0.026..0.026 rows=0 loops=1) -> Index Scan using connection_regid_obj1_index on connection (cost=0.00..4.83 rows=1 width=4) (actual time=0.011..0.012 rows=1 loops=1) Index Cond: ((connection_registry_id = 40105) AND (obj1 = 73582)) Total runtime: 0.215 ms (7 rows) This is an Opteron (in 32-bit mode), though. /* Steinar */ -- Homepage: http://www.sesse.net/