Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id A8E821337B67 for ; Wed, 11 May 2011 14:00:37 -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 77504-08 for ; Wed, 11 May 2011 17:00:29 +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 EA0BA1337B47 for ; Wed, 11 May 2011 14:00:28 -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 p4BH0RNm000509; Wed, 11 May 2011 13:00:27 -0400 (EDT) To: Robert Haas cc: Lucas Madar , pgsql-performance@postgresql.org Subject: Re: Poor performance when joining against inherited tables In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Wed, 11 May 2011 12:38:44 -0400" Date: Wed, 11 May 2011 13:00:26 -0400 Message-ID: <508.1305133226@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/155 X-Sequence-Number: 43664 Robert Haas writes: > A more interesting question is why you're not getting a plan like this: > Nested Loop > -> Seq Scan on objects > -> Append > -> Index Scan using xxx_pkey on itemXX > -> Index Scan using yyy_pkey on itemYY > -> Index Scan using zzz_pkey on itemZZ Probably because there are 4 million rows in the objects table. Or maybe it's a pre-8.2 database and can't even generate such a plan. But if it did generate it, it would almost certainly have decided that this was more expensive than a hash or merge join. People have this weird idea that the existence of an index ought to make enormous joins free ... regards, tom lane