Re: Mystery function error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Richard Sydney-Smith <richard(at)ibisaustralia(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Mystery function error
Date: 2003-09-28 18:29:14
Message-ID: 10187.1064773754@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I said:
> [hmm, I wonder why plpgsql seems to have gotten slower in 7.4...]

False alarm --- or at least, it wasn't plpgsql's fault. I copied Joe's
function definition, which was

CREATE OR REPLACE FUNCTION public.locate(bpchar, bpchar) RETURNS int4 AS '

But since position() takes arguments of type TEXT, there are two
bpchar->text coercions involved inside the function. This was a "free"
binary coercion in 7.3, but 7.4 interprets it as invoking rtrim().
The extra rtrim operations account for most of the slowdown.

Using functions declared like "locate(text, text)" to avoid the unwanted
type coercions, I get these kinds of numbers:

7.4 7.3

position() 1 usec/call 1 usec/call
SQL func 1 usec/call 90 usec/call
plpgsql func 110 usec/call 100 usec/call

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2003-09-28 18:47:41 Re: Mystery function error
Previous Message Muhyiddin A.M Hayat 2003-09-28 18:01:14 SUM() & GROUP BY