"Graham Vickrage" <[EMAIL PROTECTED]> writes:
>> CREATE FUNCTION get_url_hits (varchar, int4) RETURNS int4 AS '
>> DECLARE
>> num INT4;
>> BEGIN
>> SELECT count(*) INTO num FROM statistics WHERE url = $1 and
>> website_id = $2;
> [ is slow ]
A possible gotcha is if the url and website_id column
> I have a table with 650k rows with an index on URL (pg v7.0.0 on
> i686-pc-linux-gnu)
>
> When using psql the select query behaves as expected i.e. takes < 1 second
> (and explain tells me it is using the correct index)
>
> However when I put this into a pl function it takes about 2.5 mins, H