Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 9EB3F9FB6E8 for ; Tue, 27 Mar 2007 08:34:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 83263-03-2 for ; Tue, 27 Mar 2007 08:34:01 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mx3.ipf.is (man.ipf.is [85.197.192.163]) by postgresql.org (Postfix) with ESMTP id 2ADC99FB6E4 for ; Tue, 27 Mar 2007 08:34:04 -0300 (ADT) Received: (qmail 31184 invoked by uid 1010); 27 Mar 2007 11:18:11 +0000 Received: from 88.149.106.19 by man (envelope-from , uid 1008) with qmail-scanner-1.25-st-qms (clamdscan: 0.88.4/1639. spamassassin: 3.1.4. perlscan: 1.25-st-qms. Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 0.806537 secs); 27 Mar 2007 11:18:11 -0000 X-Antivirus-HIVE-Mail-From: gnari@hive.is via man X-Antivirus-HIVE: 1.25-st-qms (Clear:RC:1(88.149.106.19):SA:0(-2.5/4.5):. Processed in 0.806537 secs Process 31176) Received: from dsl-149-106-19.hive.is (HELO ?192.168.1.33?) (88.149.106.19) by mx3.ipf.is with SMTP; 27 Mar 2007 11:18:10 +0000 Subject: Re: Nested Loop From: Ragnar To: Gauri Kanekar Cc: pgsql-performance@postgresql.org In-Reply-To: <7e4ba9550703270343o4dadf1c0sdcf9f06eba64ed00@mail.gmail.com> References: <7e4ba9550703260504u6e9402ferd958620c79e9640a@mail.gmail.com> <20070326140549.GA9322@winnie.fuhr.org> <7e4ba9550703260803l16b86ef0w42182ef762837db8@mail.gmail.com> <1174926153.1153.31.camel@localhost.localdomain> <7e4ba9550703270343o4dadf1c0sdcf9f06eba64ed00@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1 Date: Tue, 27 Mar 2007 11:47:13 +0000 Message-Id: <1174996033.1153.68.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.8.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200703/401 X-Sequence-Number: 23806 On ūri, 2007-03-27 at 16:13 +0530, Gauri Kanekar wrote: > > SELECT rs.id AS sid, rs.name AS sname, rc.id AS campid, rc.name AS > campname, rc.rev_type AS revtype, rc.act_type AS actntype, ra.id AS > advid, ra.name AS advname, rpt_chn.id AS chanid, rpt_chn.name AS > channame, rpt_cre.dn AS dn, SUM(rm.imdel) AS impression, SUM(rm.cdel) > AS click, rd.sqldate AS date FROM rm, rn CROSS JOIN rd, ra, rs, rc, > rpt_chn, rpt_cre WHERE rm.date_key = rd.key AND rm.net_key = rn.key > AND rm.adv_key = ra.key AND rm.camp_key = rc.key AND rm.s_key = rs.key > AND rm.chn_key = rpt_chn.key AND rm.cre_key = rpt_cre.key AND > ra.name != 'SYSTEM' AND rd.sqldate BETWEEN '12/1/2006' AND > '12/30/2006' AND ( rn.id IN ( 607 ) ) GROUP BY rd.sqldate , rs.id, > rs.name, ra.id, ra.name, rc.id, rc.name, rc.rev_type , rc.act_type, > rpt_chn.id, rpt_chn.name, rpt_cre.dn; you did not answer other questions, so do this: 1) VACUUM ANALYZE your database 2) set these in your postgresql.conf: enable_seqscan = true join_collapse_limit = 8 3) restart postgresql 4) do the EXPLAIN ANALYZE again, and send us it's output gnari