Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 6598C1337B83 for ; Thu, 14 Apr 2011 11:11:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 31703-03 for ; Thu, 14 Apr 2011 14:10:48 +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 924AC1337B80 for ; Thu, 14 Apr 2011 11:10:46 -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 p3EEAiWR013173; Thu, 14 Apr 2011 10:10:44 -0400 (EDT) To: =?iso-8859-1?Q?V=E1clav_Ovs=EDk?= cc: pgsql-performance@postgresql.org Subject: Re: poor execution plan because column dependence In-reply-to: <20110414081152.GB11328@bobek.localdomain> References: <20110412232343.GA15966@bobek.localdomain> <20568.1302655935@sss.pgh.pa.us> <20110413082139.GB24050@bobek.localdomain> <6361.1302711846@sss.pgh.pa.us> <20110414081152.GB11328@bobek.localdomain> Comments: In-reply-to =?iso-8859-1?Q?V=E1clav_Ovs=EDk?= message dated "Thu, 14 Apr 2011 10:11:52 +0200" Date: Thu, 14 Apr 2011 10:10:44 -0400 Message-ID: <13172.1302790244@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: 201104/215 X-Sequence-Number: 43277 =?iso-8859-1?Q?V=E1clav_Ovs=EDk?= writes: > I'm not certain about your sentence touching int4eq() and index. The > execution plan as show in my previous mail contains information about > using index tickets5: > -> Index Scan using tickets5 on tickets main (cost=0.00..4.38 rows=1 width=162) (actual time=0.006..0.006 rows=0 loops=15593) > Index Cond: (main.id = transactions_1.objectid) > Filter: (((main.status)::text <> 'deleted'::text) AND (main.lastupdated > '2008-12-31 23:00:00'::timestamp without time zone) AND (main.created > '2005-12-31 23:00:00'::timestamp without time zone) AND int4eq(main.effectiveid, main.id) AND (main.queue = 15) AND ((main.type)::text = 'ticket'::text) AND ((main.status)::text = 'resolved'::text)) > That means tickets5 index was used for int4eq(main.effectiveid, main.id). > Is it right? Or am I something missing? No, the clause that's being used with the index is main.id = transactions_1.objectid The "filter condition" is just along for the ride --- it doesn't matter what sort of expressions are in there, so long as they only use variables available at this point in the plan. But if you had coded that clause as int4eq(main.id, transactions_1.objectid) it would have been unable to create this plan at all. regards, tom lane