constant vs function param differs in performance - Mailing list pgsql-performance

From SZŰCS Gábor
Subject constant vs function param differs in performance
Date
Msg-id 01a601c3aac1$281e72c0$0403a8c0@fejleszt4
Whole thread Raw
Responses Re: constant vs function param differs in performance
List pgsql-performance
Dear Gurus,

I have two SQL function that produce different times and I can't understand
why. Here is the basic difference between them:

CREATE FUNCTION test_const_1234 () RETURNS int4 AS '
  SELECT ... 1234 ... 1234 .... 1234 ...
' LANGUAGE 'SQL';

CREATE FUNCTION test_param (int4) RETURNS int4 AS '
  SELECT ... $1 .... $1 .... $1 ...
' LANGUAGE 'SQL';

Some sample times for different data:

test_const_1234()     450 msec
test_param(1234)     2700-4000 msec (probably disk cache)
test_const_5678()   13500 msec
test_param(5678)    14500 msec

Is there a sane explanation? a solution?
I can send more info if you wish.

TIA,
G.
------------------------------- cut here -------------------------------


pgsql-performance by date:

Previous
From: Christopher Browne
Date:
Subject: Re: Help with count(*)
Next
From: "Nick Fankhauser"
Date:
Subject: Re: Seeking help with a query that takes too long