Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id F0240632480 for ; Wed, 21 Jan 2009 11:53:04 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 22080-01 for ; Wed, 21 Jan 2009 11:53:01 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 3C355632417 for ; Wed, 21 Jan 2009 11:53:01 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n0LFpeQj002613; Wed, 21 Jan 2009 10:51:40 -0500 (EST) To: Michael Monnerie cc: pgsql-admin@postgresql.org Subject: Re: Why is that index not used? In-reply-to: <200901211634.42228@zmi.at> References: <200901211634.42228@zmi.at> Comments: In-reply-to Michael Monnerie message dated "Wed, 21 Jan 2009 16:34:42 +0100" Date: Wed, 21 Jan 2009 10:51:40 -0500 Message-ID: <2612.1232553100@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200901/97 X-Sequence-Number: 31144 Michael Monnerie writes: > Can somebody explain me why on the last line, "dbmail_physmessage", > there is a seq. scan going on and no index used? Because it chose to use a hash instead. Given the rowcounts I don't think that's wrong, but if you want to see the other plan you can try setting enable_hashjoin = off (and maybe enable mergejoin = off if it goes to a merge join next). As for your other question, the reason it likes the dbmail_messages_1 index is probably that it's a lot smaller than dbmail_messages_7. The only thing I'm seeing that seems curious is that when forced to use dbmail_messages_7, it isn't using what seems to be an available index condition. regards, tom lane