From: Craig A. James <cjames@modgraph-usa.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-performance@postgresql.org
Subject: Re: Trivial function query optimized badly
Date: Wed, 03 Jan 2007 22:57:05 -0800
Message-ID: <459CA541.3060009@modgraph-usa.com> (raw)
In-Reply-To: <12930.1167889610@sss.pgh.pa.us>
References: <459C705C.1060803@modgraph-usa.com>
<12930.1167889610@sss.pgh.pa.us>
Tom Lane wrote:
> "Craig A. James" <cjames@modgraph-usa.com> 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.
Good catch, mystery solved. There are two definitions for this function, the first just a "wrapper" for the second with the latter parameter defaulting to "1". The second definition was missing the "IMMUTABLE" keyword.
Thanks!
Craig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: cjames@modgraph-usa.com, tgl@sss.pgh.pa.us
Subject: Re: Trivial function query optimized badly
In-Reply-To: <459CA541.3060009@modgraph-usa.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox