Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 0B9209FA0B7 for ; Thu, 4 Jan 2007 01:46:59 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 51273-08 for ; Thu, 4 Jan 2007 01:46:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 631C49F9FDA for ; Thu, 4 Jan 2007 01:46:52 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l045koU2012931; Thu, 4 Jan 2007 00:46:50 -0500 (EST) To: "Craig A. James" cc: pgsql-performance@postgresql.org Subject: Re: Trivial function query optimized badly In-reply-to: <459C705C.1060803@modgraph-usa.com> References: <459C705C.1060803@modgraph-usa.com> Comments: In-reply-to "Craig A. James" message dated "Wed, 03 Jan 2007 19:11:24 -0800" Date: Thu, 04 Jan 2007 00:46:50 -0500 Message-ID: <12930.1167889610@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/50 X-Sequence-Number: 22651 "Craig A. James" writes: > CREATE OR REPLACE FUNCTION cansmiles(text) RETURNS text > AS '/usr/local/pgsql/lib/libchem.so', 'cansmiles' > LANGUAGE 'C' STRICT IMMUTABLE; Umm ... this is a single-argument function. > db=> explain analyze select version_id, 'Brc1ccc2nc(cn2c1)C(=O)O' from version where version.isosmiles = cansmiles('Brc1ccc2nc(cn2c1)C(=O)O', 1); And this query is invoking some other, two-argument function; which apparently hasn't been marked IMMUTABLE, else it'd have been folded to a constant. regards, tom lane