Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id EEDA713364DE for ; Tue, 12 Apr 2011 06:33:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 45842-02 for ; Tue, 12 Apr 2011 09:33:32 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from elizabeth.gransy.com (elizabeth.gransy.com [89.187.132.199]) by mail.postgresql.org (Postfix) with ESMTP id 728E2133616B for ; Tue, 12 Apr 2011 06:33:32 -0300 (ADT) Received: from sq.gransy.com (localhost [127.0.0.1]) by elizabeth.gransy.com (Postfix) with ESMTP id 3A88C15E410A; Tue, 12 Apr 2011 11:33:31 +0200 (CEST) Received: from 85.162.91.74 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Tue, 12 Apr 2011 11:33:31 +0200 Message-ID: <85b1e68e7ad292e4cae8fcfd8c8cb61a.squirrel@sq.gransy.com> In-Reply-To: References: <152FFD9B-A288-4329-9C96-0FF0C6A2D418@skiline.cc> Date: Tue, 12 Apr 2011 11:33:31 +0200 Subject: Re: performance problem with LIMIT (order BY in DESC order). Wrong index used? From: tv@fuzzy.cz To: "Claudio Freire" Cc: "Dieter Rehbein" , pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.21 MIME-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201104/151 X-Sequence-Number: 43213 > On Tue, Apr 12, 2011 at 10:59 AM, Dieter Rehbein > wrote: >> I just executed a VACUUM ANALYZE and now everything performs well. hm, >> strange. > > That probably means you need more statistics - try increasing the > newsfeed's statistics target count. > > ALTER TABLE newsfeed_item ALTER COLUMN newsfeed SET STATISTICS ; > > Try different numbers, you can crank it up to 4000 or perhaps more > in 9.0, but you should start lower I guess. AFAIK the max value is 10000 and the default is 100. Higher numbers mean higher overhead, so do not jump to 10000 directly. Set it to 1000 and see if that helps, etc. regards Tomas