Received: from nts1.rtp.epa.gov (nts1.rtp.epa.gov [134.67.208.208]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0VHgPq56886 for ; Wed, 31 Jan 2001 12:42:25 -0500 (EST) (envelope-from volpe.mark@epamail.epa.gov) Received: from epamail.epa.gov (scanmeifyoudare.rtp.epa.gov [134.67.139.14]) by nts1.rtp.epa.gov (8.9.3/8.9.3) with ESMTP id MAA06788; Wed, 31 Jan 2001 12:46:40 -0500 (EST) Message-ID: <3A784E69.ECCAAB30@epamail.epa.gov> Date: Wed, 31 Jan 2001 12:42:01 -0500 From: Mark Volpe X-Mailer: Mozilla 4.75 [en] (X11; U; Linux 2.2.17-21mdk i686) X-Accept-Language: en MIME-Version: 1.0 To: Najm Hashmi CC: "pgsql-sql@postgresql.org" Subject: Re: Index scan References: <3A7996AC.AD99A45B@mondo-live.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200101/486 X-Sequence-Number: 1162 Since you are selecting all the rows of media, there is no reason to use the index to do this as it would just slow things down. Mark Najm Hashmi wrote: > > Hi all, > I am unable to understand why my inidcies are not used in the query. > I have following indices: > index on categories.root > index on media.category > unique index on categories.id > Here is my query : > mondo=# explain select m.id > form media m, categories c > where c.id=m.category and c.root like 'B%'; > NOTICE: QUERY PLAN: > > Hash Join (cost=22.55..116.80 rows=11 width=28) > -> Seq Scan on media m (cost=0.00..60.40 rows=840 width=16) > -> Hash (cost=22.50..22.50 rows=20 width=12) > -> Index Scan using cat_id_root on categories c > (cost=0.00..22.50 rows=20 width=12) > EXPLAIN > > I simply dont understand why it uses seq scan on media. > Thanks all for your help. > -Najm