Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 53194133616B for ; Fri, 11 Feb 2011 14:51:59 -0400 (AST) 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 05796-04 for ; Fri, 11 Feb 2011 18:51:51 +0000 (UTC) X-Greylist: delayed 03:33:22.132289 by SQLgrey-1.7.6 Received: from 26.mail-out.ovh.net (9.26.mail-out.ovh.net [46.105.56.220]) by mail.postgresql.org (Postfix) with SMTP id DCA071337C05 for ; Fri, 11 Feb 2011 14:51:50 -0400 (AST) Received: (qmail 4703 invoked by uid 503); 11 Feb 2011 14:19:32 -0000 Received: from b6.ovh.net (HELO mail612.ha.ovh.net) (213.186.33.56) by 26.mail-out.ovh.net with SMTP; 11 Feb 2011 14:19:31 -0000 Received: from b0.ovh.net (HELO queueout) (213.186.33.50) by b0.ovh.net with SMTP; 11 Feb 2011 16:51:46 +0200 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13) (lists%peufeu.com@88.161.102.87) by ns0.ovh.net with SMTP; 11 Feb 2011 16:51:46 +0200 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: "Josh Berkus" , "Tobias Brox" Cc: pgsql-performance@postgresql.org, "Mladen Gogala" Subject: Re: Why we don't want hints Was: Slow count(*) again... References: <201102012247.p11Ml6u02682@momjian.us> <4D489AD1.1010105@vmsinfo.com> <4D499E55.4020107@vmsinfo.com> <4D49A6B9.4060608@2ndquadrant.com> <4D49C482.4010707@vmsinfo.com> <4D49F0BA.9000901@2ndquadrant.com> <4D4A16BF.1020304@vmsinfo.com> <4D4A4844.3020409@2ndquadrant.com> <4D4AD9F6.6040903@vmsinfo.com> <4D4AE16E.9040807@peak6.com> <4D4B17B4.9030406@vmsinfo.com> <4D4B1F5B.4060403@peak6.com> <4D4B261B.6010303@vmsinfo.com> <4D4B2E8A.7010402@vmsinfo.com> <4D4B3395.6010007@agliodbs.com> <4D4B394E.9080505@vmsinfo.com> <4D4B5A73.3080302@agliodbs.com> Date: Fri, 11 Feb 2011 15:51:44 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Pierre C" Message-ID: In-Reply-To: User-Agent: Opera Mail/10.63 (Linux) X-Ovh-Tracer-Id: 5548997691397441127 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|U 0.5/N 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: 201102/353 X-Sequence-Number: 42491 > select * from account_transaction where trans_type_id in ( ... > long, hard-coded list ...) and account_id=? order by created desc > limit 25; You could use an index on (account_id, created, trans_type), in replacement of your index on (account_id, created). This will not prevent the "Index Scan Backwards", but at least, index rows with trans_type not matching the WHERE clause will not generate any heap access...