Re: [PERFORM] Slow function in queries SELECT clause.

2010-08-12 Thread Davor J.
> "Tom Lane" wrote in message > news:25116.1277047...@sss.pgh.pa.us... >> "Davor J." writes: >>> Suppose 2 functions: factor(int,int) and offset(int, int). >>> Suppose a third function: convert(float,int,int) which simply returns >>> $1*factor($2,$3)+offset($2,$3) >>> All three functions are IMM

Re: [PERFORM] Slow function in queries SELECT clause.

2010-06-21 Thread Davor J.
Thanks Tom, Your concepts of "inlining" and "black box" really cleared things up for me. With fnc_unit_convert() written in SQL and declared as STABLE I indeed have fast performance now. I appreciate the note on the IMMUTABLE part. The table contents should not change in a way to affect the fu

Re: [PERFORM] Slow function in queries SELECT clause.

2010-06-20 Thread Tom Lane
"Davor J." writes: > Suppose 2 functions: factor(int,int) and offset(int, int). > Suppose a third function: convert(float,int,int) which simply returns > $1*factor($2,$3)+offset($2,$3) > All three functions are IMMUTABLE. You should write the third function as a SQL function, which'd allow it to

Re: [PERFORM] Slow function in queries SELECT clause.

2010-06-20 Thread Davor J.
I didn't consider them to be important as they showed the same, only the execution time was different. Also, they are a bit more complex than the ones put in the previous post. But here they are: Definitions: --- CREATE OR REPLACE FUNCTION

Re: [PERFORM] Slow function in queries SELECT clause.

2010-06-20 Thread Szymon Guz
2010/6/19 Davor J. > I think I have read what is to be read about queries being prepared in > plpgsql functions, but I still can not explain the following, so I thought > to post it here: > > Suppose 2 functions: factor(int,int) and offset(int, int). > Suppose a third function: convert(float,int,

[PERFORM] Slow function in queries SELECT clause.

2010-06-20 Thread Davor J.
I think I have read what is to be read about queries being prepared in plpgsql functions, but I still can not explain the following, so I thought to post it here: Suppose 2 functions: factor(int,int) and offset(int, int). Suppose a third function: convert(float,int,int) which simply returns $1*