Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5F6571337B9E for ; Mon, 17 Jan 2011 16:51:41 -0400 (AST) 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 61407-06 for ; Mon, 17 Jan 2011 20:51:34 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id C0CC6133740B for ; Mon, 17 Jan 2011 16:51:33 -0400 (AST) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Mon, 17 Jan 2011 14:51:32 -0600 Message-Id: <4D34576C02000025000396CB@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Mon, 17 Jan 2011 14:51:24 -0600 From: "Kevin Grittner" To: , Subject: Re: Bad plan when join on function Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.21 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201101/137 X-Sequence-Number: 41924 Zotov wrote: > select c.id from OneRow c join abstract a on a.id=AsInteger(c.id) > Why SeqScan??? Because you don't have an index on AsInteger(c.id). If your function is IMMUTABLE (each possible combination of input values always yields the same result), and you declare it such, then you can index on the function, and it will perform at a speed similar to the other example. -Kevin