Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 87322475B87 for ; Wed, 3 Jul 2002 04:46:35 -0400 (EDT) Mailbox-Line: From achill@matrix.gatewaynet.com Wed Jul 3 04:46:35 2002 Received: from matrix.gatewaynet.com (unknown [217.19.69.50]) by postgresql.org (Postfix) with ESMTP id E8051475E17 for ; Wed, 3 Jul 2002 03:56:17 -0400 (EDT) Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.11.6/8.11.6) with ESMTP id g637sYc13206; Wed, 3 Jul 2002 10:54:34 +0300 Date: Wed, 3 Jul 2002 10:54:34 +0300 (EEST) From: Achilleus Mantzios To: Ahti Legonkov Cc: pgsql-sql@postgresql.org Subject: Re: Why doesn't it use indexes? In-Reply-To: <3D21CAF3.8090508@127.0.0.1> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=-2.5 required=5.0 tests=IN_REP_TO,X_NOT_PRESENT,SUBJ_ENDS_IN_Q_MARK, DOUBLE_CAPSWORD,NO_MX_FOR_FROM version=2.30 X-Spam-Level: X-Archive-Number: 200207/25 X-Sequence-Number: 8404 On Tue, 2 Jul 2002, Ahti Legonkov wrote: Check the actual time by explain analyze. If sequential scan (your table is small e.g.) is faster then there is no need for index use. Also check the enable_indexscan variable. > Hi, > > I have this query: > select * from reo inner join usr on reo.owner_id=usr.user_id > > I also have created these indexes: > CREATE INDEX "owner_id_reo_key" ON reo (owner_id); > CREATE INDEX "user_id_user_key" ON usr (user_id); > > Explain tells me this: > Merge Join (cost=1341.74..1481.12 rows=299697 width=461) > -> Sort (cost=775.05..775.05 rows=6629 width=328) > -> Seq Scan on apartment_reo reo (cost=0.00..354.29 rows=6629 > width=328) > -> Sort (cost=566.69..566.69 rows=4521 width=133) > -> Seq Scan on USER usr (cost=0.00..292.21 rows=4521 width=133) > > Why it does not use indexes I have created? > > -- Achilleus Mantzios S/W Engineer IT dept Dynacom Tankers Mngmt tel: +30-10-8981112 fax: +30-10-8981877 email: achill@matrix.gatewaynet.com mantzios@softlab.ece.ntua.gr