Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id F22EC64021D for ; Wed, 25 Mar 2009 18:56:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 00223-06-4 for ; Wed, 25 Mar 2009 18:55:53 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outmail128075.authsmtp.co.uk (outmail128075.authsmtp.co.uk [62.13.128.75]) by mail.postgresql.org (Postfix) with ESMTP id 0E52263F174 for ; Wed, 25 Mar 2009 18:55:46 -0300 (ADT) Received: from mail-c189.authsmtp.com (mail-c189.authsmtp.com [62.13.128.71]) by punt4.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n2PLthpH035874; Wed, 25 Mar 2009 21:55:43 GMT Received: from Sidney-Stratton.local (adsl-63-195-55-98.dsl.snfc21.pacbell.net [63.195.55.98]) (authenticated bits=0) by mail.authsmtp.com (8.14.2/8.14.2/Kp) with ESMTP id n2PLtfNC087084; Wed, 25 Mar 2009 21:55:42 GMT Message-ID: <49CAA85C.8080402@agliodbs.com> Date: Wed, 25 Mar 2009 14:55:40 -0700 From: Josh Berkus Organization: Aglio Database Solutions User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1b3pre) Gecko/20090223 Thunderbird/3.0b2 MIME-Version: 1.0 To: Bryan Murphy CC: marcin mank , pgsql-performance@postgresql.org Subject: Re: Help Me Understand Why I'm Getting a Bad Query Plan References: <7fd310d10903231203r1bd37b8cn8baeadae83253f44@mail.gmail.com> <7fd310d10903241521v1cbf5d7aueca653e03ed98649@mail.gmail.com> <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com> In-Reply-To: <7fd310d10903242047t1a7b7daw1d61c3de7f20b7c6@mail.gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Server-Quench: afcd430c-1987-11de-bc7b-001f29070be2 X-AuthRoute: OCdyZgscClZXSx8a IioLCC5HRQ8+YBZL BAkGMA9GIUINWEQK c1AAcx12OUdbHwkB CnYJWl5RVVd1Wy1z aBRQZABDZ09QVg11 Uk1LR01SWltqYWBF UGBtUhF1dw1CNn91 ZUMsDyYICEB5dRVg Q0dcEnAHZDM1dTJM VxJFdwNVJgFDfhhF OAV9GhFYa3VsBg8C MSgJGgV5HThbMGxw T0kwK14fW10XFzgw Dy8CDH0OUkhNaCgv Mx0gJRYVVGwYPg0L LFY7SBogNxYUYiwg X-Authentic-SMTP: 61633136333939.kestrel.dmpriest.net.uk:1378/Kp X-Report-SPAM: If SPAM / abuse - report it at: http://www.authsmtp.com/abuse X-Virus-Status: No virus detected - but ensure you scan with your own anti-virus system. X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200903/369 X-Sequence-Number: 33291 Bryan, > One thing to keep in mind, due to a lapse in our judgement at the > time, this itemexperiencelog table serves as both a current state > table, and a log table. Therefore, it potentially has multiple > redundant entries, but we typically only look at the most recent entry > to figure out the state of the current item. Oh, I see. It thinks that it'll need to pull 260,000 redundant rows in order to get 1800 unique ones. Only it's wrong; you're only pulling about 4000. Try increasing some stats still further: itemexperiencelog.visitorid and visitors.user_id both to 500. --Josh