Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 5C34D634623 for ; Tue, 3 Mar 2009 13:41:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 52310-09 for ; Tue, 3 Mar 2009 13:40:59 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from qw-out-2122.google.com (qw-out-2122.google.com [74.125.92.26]) by mail.postgresql.org (Postfix) with ESMTP id 3A9A2633CA5 for ; Tue, 3 Mar 2009 13:40:54 -0400 (AST) Received: by qw-out-2122.google.com with SMTP id 5so2187660qwd.61 for ; Tue, 03 Mar 2009 09:40:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Rh5XR1Ep02UzksBlrcBZKIJkWavi0vmEtb9GSc7imEM=; b=q2D+28D5bOsnSoY7eOWp/3cDYW5bZda5NN8+qJZXMtH7ZPY0OWNM8EXUJnIzX7J50y brhGCeIyiazkDC9Fh4k9JwnEfgiEImuftblNTjuSUv9CXAz4H3zsJacx67Y9EBdgG99Q tTxPACcvNwWk/Pw3aeOjsyVjNgKfYrywtSy0E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=A70nLzo9kcUWuGSZvpfBzifKC37yy9yU1SzBwSBwLHIYBEMX7cl71T+uo3IqLuXBCE aooNwuZC8+PgpRCiyg8dt84JiZh1SqSoS5SQVGtnLM03/Z7pwVKO1r63uX2ZEkoxj/HE 4ux4kERRtKesUnZocF1GcNrwe0h+I7QEoXDX4= MIME-Version: 1.0 Received: by 10.229.83.146 with SMTP id f18mr4088322qcl.41.1236102044658; Tue, 03 Mar 2009 09:40:44 -0800 (PST) In-Reply-To: References: <603c8f070903030912t36c541ebr50b4576c7a9a5b65@mail.gmail.com> Date: Tue, 3 Mar 2009 12:40:44 -0500 Message-ID: <603c8f070903030940n3fb1e9eay53666d06cf489469@mail.gmail.com> Subject: Re: Problems with ordering (can't force query planner to use an index) From: Robert Haas To: Sebastjan Trepca Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 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: 200903/31 X-Sequence-Number: 32953 On Tue, Mar 3, 2009 at 12:20 PM, Sebastjan Trepca wrote: > But it's already attached in the first mail or am I missing something? > > If you don't see it, check this: http://pastebin.com/d71b996d0 Woops, sorry, I thought you had sent plain EXPLAIN. I see it now. The lowest level at which I see a problem is here: -> Index Scan using core_accessor_fresh_idx on core_accessor (cost=0.00..5460.07 rows=2970 width=92) (actual time=0.068..54.921 rows=69312 loops=1) Index Cond: ((slot_id = 472) AND (slot_type_id = 119) AND (label = ''::text) AND (user_id = 0) AND (role = 0) AND (publish_state >= 60)) For some reason it expect 2970 rows but gets 69312. A good place to start is to change your default_statistics_target value to 100 in postgresql.conf, restart postgresql, and re-ANALYZE. ...Robert