X-Original-To: pgsql-admin@postgresql.org Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 67CC4476350 for ; Wed, 12 Mar 2003 17:43:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.8/8.12.8) with ESMTP id h2CMhnub029953; Wed, 12 Mar 2003 17:43:49 -0500 (EST) To: Stephan Szabo Cc: Chris Mungall , pgsql-admin@postgresql.org Subject: Re: Using functions as filters in queries In-reply-to: <20030312140421.O56401-100000@megazone23.bigpanda.com> References: <20030312140421.O56401-100000@megazone23.bigpanda.com> Comments: In-reply-to Stephan Szabo message dated "Wed, 12 Mar 2003 14:10:41 -0800" Date: Wed, 12 Mar 2003 17:43:49 -0500 Message-ID: <29952.1047509029@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200303/167 X-Sequence-Number: 7807 Stephan Szabo writes: > Of course, I misread what explain did (without trying the > enable_seqscan=off case) and this is still not indexable because even > after that, you'll not get a clause on the outside that it considers > indexable. It is smart enough (7.4 anyway) to make the filter ((t.*).n)=5 > which I thought it'd index, but doesn't. :( Note that inline-expansion of SQL functions like this is new for 7.4; it's not done in any current release. I think the extra step to make this expression indexable is probably not too hard: the constant-expression folder needs to be taught that extracting a field from a whole-row Var can be replaced by a Var reference to the field, ie, fold "(t.*).n" into "t.n". regards, tom lane