Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 3095E6334FA for ; Tue, 3 Mar 2009 15:05:59 -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 42901-02 for ; Tue, 3 Mar 2009 15:05:55 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f168.google.com (mail-fx0-f168.google.com [209.85.220.168]) by mail.postgresql.org (Postfix) with ESMTP id 3D03063339A for ; Tue, 3 Mar 2009 15:05:54 -0400 (AST) Received: by fxm12 with SMTP id 12so3541857fxm.19 for ; Tue, 03 Mar 2009 11:05:53 -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=OrUoJIkzTDrvBqC22CD/RNV9Kj9f/3Q5kuz+jqsxKJw=; b=vM3WWgwoPyoTXgK53wt0RFVJP4GjG4Awp6zMQKFrdX+vmjvqnk1MAgKOWjFu3VR9UW 1Zzlbg9Ge/gL0M5E82NFKlMNCtrggWQ1HlMPmd8tmceXermgccptmbS2zN5As5a7IIb1 SnHBZ4emmH14Ne7NSHPRdOXOC1+um6/WyNHJM= 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=Ac2GFz3yazD5Ubula6vyhkk2ISgplF4rVv6M1oDrCsOTM5B2KJcyA8ZgMopdWW+gGM Jx+Ds/eBWIGCc6sxQa0ZXU1MDvgjh9uCxS/R+fi7RTbay9ib/JGNgh3R4vxijSBBjwM9 tPc1XoEoIKkk9SiAxao2NHZ0HW0DJr4pMDyL8= MIME-Version: 1.0 Received: by 10.223.126.203 with SMTP id d11mr4721894fas.22.1236107153490; Tue, 03 Mar 2009 11:05:53 -0800 (PST) In-Reply-To: <603c8f070903030940n3fb1e9eay53666d06cf489469@mail.gmail.com> References: <603c8f070903030912t36c541ebr50b4576c7a9a5b65@mail.gmail.com> <603c8f070903030940n3fb1e9eay53666d06cf489469@mail.gmail.com> Date: Tue, 3 Mar 2009 20:05:53 +0100 Message-ID: Subject: Re: Problems with ordering (can't force query planner to use an index) From: Sebastjan Trepca To: Robert Haas Cc: pgsql-performance@postgresql.org Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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/33 X-Sequence-Number: 32955 Still the same :/ I raised the default_statistics_target to 600 (it was already 100). I then restarted pg, ran analyze through all tables and yet there is not effect. This is the output for core_accessor: INFO: analyzing "public.core_accessor" INFO: "core_accessor": scanned 291230 of 291230 pages, containing 17144315 live rows and 0 dead rows; 300000 rows in sample, 17144315 estimated total rows It thinks there are even less rows in the set: ---------------------------------------------------------------------------= ---------------------------------------------------------------------------= --------------- Limit (cost=3D30816.49..30816.50 rows=3D5 width=3D855) (actual time=3D683.907..683.910 rows=3D5 loops=3D1) -> Sort (cost=3D30816.49..30822.29 rows=3D2321 width=3D855) (actual time=3D683.906..683.907 rows=3D5 loops=3D1) Sort Key: core_accessor.date_posted, core_accessor.nooximity Sort Method: top-N heapsort Memory: 31kB -> Nested Loop (cost=3D0.00..30777.94 rows=3D2321 width=3D855) (actual time=3D0.072..517.970 rows=3D68505 loops=3D1) -> Index Scan using core_accessor_fresh_idx on core_accessor (cost=3D0.00..8955.44 rows=3D2440 width=3D92) (actual time=3D0.056..53.107 rows=3D69312 loops=3D1) Index Cond: ((slot_id =3D 472) AND (slot_type_id =3D 119) AND (label =3D ''::text) AND (user_id =3D 0) AND (role =3D 0) AND (publish_state >=3D 60)) -> Index Scan using core_base_pkey on core_base (cost=3D0.00..8.93 rows=3D1 width=3D763) (actual time=3D0.004..0.005 rows= =3D1 loops=3D69312) Index Cond: ((core_base.object_id =3D core_accessor.object_id) AND (core_base.content_type_id =3D core_accessor.content_type_id)) Total runtime: 684.015 ms (10 rows) Sebastjan On Tue, Mar 3, 2009 at 6:40 PM, Robert Haas wrote: > On Tue, Mar 3, 2009 at 12:20 PM, Sebastjan Trepca wrot= e: >> 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. =C2=A0I see it now. > > The lowest level at which I see a problem is here: > > -> =C2=A0Index Scan using core_accessor_fresh_idx on core_accessor > (cost=3D0.00..5460.07 rows=3D2970 width=3D92) (actual time=3D0.068..54.92= 1 > rows=3D69312 loops=3D1) > =C2=A0 =C2=A0Index Cond: ((slot_id =3D 472) AND (slot_type_id =3D 119) AN= D (label =3D > ''::text) AND (user_id =3D 0) AND (role =3D 0) AND (publish_state >=3D 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 >