Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id C537364FCEF for ; Tue, 26 Aug 2008 13:53:13 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 73558-03 for ; Tue, 26 Aug 2008 13:53:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id BE36664FCC0 for ; Tue, 26 Aug 2008 13:53:10 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m7QGr9jL010026; Tue, 26 Aug 2008 12:53:09 -0400 (EDT) To: "Frank Joerdens" cc: pgsql-performance@postgresql.org, Nic , "Seb Potter" Subject: Re: Query w empty result set with LIMIT orders of magnitude slower than without In-reply-to: <7d10d2df0808260937v3103e216h764bbb74ca597d6f@mail.gmail.com> References: <7d10d2df0808260937v3103e216h764bbb74ca597d6f@mail.gmail.com> Comments: In-reply-to "Frank Joerdens" message dated "Tue, 26 Aug 2008 17:37:32 +0100" Date: Tue, 26 Aug 2008 12:53:09 -0400 Message-ID: <10025.1219769589@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200808/333 X-Sequence-Number: 31214 "Frank Joerdens" writes: > It seems to me that the planner makes a very poor decision with this > particular query: Try increasing the stats on woouser. You need it to make a smaller estimate of the number of matching rows here: > -> Index Scan Backward using webapp_invite_pkey on > webapp_invite (cost=0.00..201698.51 rows=382 width=44) (actual > time=2545.131..2545.131 rows=0 loops=1) > Filter: ((woouser)::text = 'suggus'::text) regards, tom lane