Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id DA04A1337C0B for ; Thu, 5 May 2011 17:27:50 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 81244-02-5 for ; Thu, 5 May 2011 20:27:43 +0000 (UTC) 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 mail.postgresql.org (Postfix) with ESMTP id 7282E1337C1E for ; Thu, 5 May 2011 17:27:18 -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 p45KRFWQ009178; Thu, 5 May 2011 16:27:15 -0400 (EDT) To: Brian Connolly cc: pgsql-performance@postgresql.org Subject: Re: Poor query plan chosen in 9.0.3 vs 8.3.7 In-reply-to: References: Comments: In-reply-to Brian Connolly message dated "Thu, 05 May 2011 10:43:37 -0700" Date: Thu, 05 May 2011 16:27:15 -0400 Message-ID: <9177.1304627235@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201105/68 X-Sequence-Number: 43577 Brian Connolly writes: > Any help that you can provide would be greatly appreciated. I'd suggest trying to get rid of the weird little subselects, like this one: > ... SELECT * FROM assayresult."c69d129_particle_size_result_fields" > WHERE (((SELECT Container FROM exp.Data WHERE RowId = DataId) IN > ('d938da12-1b43-102d-a8a2-78911b79dd1c'))) ... If you turned that into a regular join between c69d129_particle_size_result_fields and Data, the planner probably wouldn't be nearly as confused about how many rows would result. It's the way-off rowcount estimate for this construct that's causing most of the problem, AFAICS: -> Seq Scan on c69d129_particle_size_result_fields (cost=0.00..229742.02 rows=348 width=59) (actual time=0.018..572.402 rows=69654 loops=1) Filter: (((SubPlan 3))::text = 'd938da12-1b43-102d-a8a2-78911b79dd1c'::text) SubPlan 3 -> Index Scan using pk_data on data (cost=0.00..3.27 rows=1 width=37) (actual time=0.004..0.005 rows=1 loops=69654) Index Cond: (rowid = $2) regards, tom lane