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 000D432A13F for ; Tue, 12 Oct 2004 05:55:46 +0100 (BST) 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 84330-06 for ; Tue, 12 Oct 2004 04:55:37 +0000 (GMT) Received: from mail1.acecape.com (mail1.acecape.com [66.114.74.12]) by svr1.postgresql.org (Postfix) with ESMTP id 510B332C241 for ; Tue, 12 Oct 2004 05:55:36 +0100 (BST) Received: from p65-147.acedsl.com (p65-147.acedsl.com [66.114.65.147]) by mail1.acecape.com (8.12.11/8.12.11) with ESMTP id i9C4tX7c016065; Tue, 12 Oct 2004 00:55:33 -0400 Date: Tue, 12 Oct 2004 00:56:15 -0400 (EDT) From: Francisco Reyes X-X-Sender: fran@zoraida.natserv.net To: John Meinel Cc: pgsql-performance@postgresql.org Subject: Re: why my query is not using index?? In-Reply-To: <416B217D.9090000@johnmeinel.com> Message-ID: <20041012005231.U98867@zoraida.natserv.net> References: <41639F3C.4050103@siche.net> <200410111425.02671.vygen@gmx.de> <20041011163756.M97379@zoraida.natserv.net> <416B217D.9090000@johnmeinel.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed 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: 200410/153 X-Sequence-Number: 8629 On Mon, 11 Oct 2004, John Meinel wrote: > Postgres believes that it will cost 382 to do a sequential scan, versus 490 > for an indexed scan. Hence why it prefers to do the sequential scan. Try > running explain analyze to see if how accurate it is. With explain analyze I have with sequential scan on Sort (cost=382.01..382.15 rows=56 width=196) (actual time=64.346..64.469 rows=24 loops=1) And with seqscan off Sort (cost=490.82..490.96 rows=56 width=196) (actual time=56.668..56.789 rows=24 loops=1) So I guess that for this particular query I am better off setting the seqscan off.