Re: Mystery function error

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Mystery function error
Дата
Msg-id 10187.1064773754@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Mystery function error  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Mystery function error
Список 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Mystery function error
Следующее
От: "Muhyiddin A.M Hayat"
Дата:
Сообщение: SUM() & GROUP BY