X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C391C9DC9E4 for ; Mon, 6 Mar 2006 16:50:28 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 03471-05 for ; Mon, 6 Mar 2006 16:50:28 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mx1.hive.is (scania.ipf.is [85.197.192.147]) by postgresql.org (Postfix) with SMTP id 451AD9DC8A7 for ; Mon, 6 Mar 2006 16:50:22 -0400 (AST) Received: (qmail 93030 invoked by uid 1010); 6 Mar 2006 20:50:42 -0000 Received: from 85.197.216.186 by scania.ipf.is (envelope-from , uid 1009) with qmail-scanner-1.25-st-qms (clamdscan: 0.88/1283. spamassassin: 3.1.0. perlscan: 1.25-st-qms. Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. Processed in 7.472889 secs); 06 Mar 2006 20:50:42 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via scania.ipf.is X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(85.197.216.186):SA:0(-4.1/4.0):. Processed in 7.472889 secs Process 92861) Received: from dsl-216-186.hive.is (HELO ?192.168.1.34?) (85.197.216.186) by mx1.hive.is with SMTP; 6 Mar 2006 20:50:32 -0000 Subject: Re: Sequencial scan instead of using index From: Ragnar To: Harry Hehl Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain; charset=ISO-8859-1 Date: Mon, 06 Mar 2006 20:51:46 +0000 Message-Id: <1141678306.18656.152.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.147 required=5 tests=[AWL=0.147] X-Spam-Score: 0.147 X-Spam-Level: X-Archive-Number: 200603/46 X-Sequence-Number: 17483 On mán, 2006-03-06 at 13:46 -0500, Harry Hehl wrote: > Query: select * from ommemberrelation where srcobj='somevalue' > and dstobj in (select objectid from omfilesysentry where name='dir15_file80'); > > Columns srcobj, dstobj & name are all indexed. > -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > Nested Loop IN Join (cost=486.19..101533.99 rows=33989 width=177) (actual time=5.493..90.682 rows=1 loops=1) > Join Filter: ("outer".dstobj = "inner".objectid) > -> Seq Scan on ommemberrelation (cost=0.00..2394.72 rows=33989 width=177) (actual time=0.078..70.887 rows=100 loops=1) > Filter: (srcobj = '3197a4e6-abf1-11da-a0f9-000fb05ab829'::text) > -> Materialize (cost=486.19..487.48 rows=129 width=16) (actual time=0.004..0.101 rows=26 loops=100) Looks like the planner is expecting 33989 rows, making an index scan a ppor choice, but in fact only 100 rows actually match your srcobj value. Could we see the explain analyze with enable_seqscan = false please ? Possibly you might want totry to increase the statistics target for this columns , as in: ALTER TABLE ommemberrelation ALTER COLUMN srcobj SET STATISTICS 1000; ANALYZE; and try again (with enable_seqscan=true) A target of 1000 ismost probably overkill, but start with this value, and if it improves matters, you can experiment with lower settings. gnari