Re: [SQL] Slow performance on MAX(primary_key)

2002-10-14 Thread Ludwig Lim
Hi Keith: --- Keith Gray <[EMAIL PROTECTED]> wrote: > Help, > > I have just been comparing some large table > performance > under 7.1 using the > > select max(primary key)from table; > > We are using this for various functions including > sequence. > Try using the following as alter

[SQL] SQL function triggers

2002-10-14 Thread Brian Blaha
I would like to write a function as a set of SQL statements, and then use that function in a trigger. However, since triggers require a return type of opaque, and SQL functions cannot return type opaque, this doesn't look possible. Am I missing something? The SQL that I would expect to do this

[SQL] Slow performance on MAX(primary_key)

2002-10-14 Thread Keith Gray
Help, I have just been comparing some large table performance under 7.1 using the select max(primary key)from table; We are using this for various functions including sequence. It is taking 9 seconds to return this from around 1 million records. Shouldn't this be an instantaneous look

Re: [SQL] Stored procedure returning row or resultset

2002-10-14 Thread Tom Lane
Richard Huxton <[EMAIL PROTECTED]> writes: > Have you looked at marking f1() etc cachable? This means Postgresql > will only call the function once for each parameter-set. Unfortunately that's not true at all, or at least not helpful for this problem. The cachable attribute was poorly named, bec

Re: [SQL] Stored procedure returning row or resultset

2002-10-14 Thread Richard Huxton
On Monday 14 Oct 2002 3:22 pm, Heiko Stoermer wrote: > Hello, > > I'm trying to achieve the following with pl/pgsql in postgres 7.2: > > I need a stored procedure proc() that calculates values for some fields > a = f1() > b = a + f2() > c = b + f3() > and returns the tuple (a,b,c) as a rowtype, M

Re: [SQL] Stored procedure returning row or resultset

2002-10-14 Thread Brian Blaha
If your f1, f2, and f3 functions depend only on their arguments; that is, if you call one of those functions with the same set of arguments, it will return the same answer every time, you can define the functions as "iscachable" as follows: create function f1() ... language ... with (iscachable

[SQL] Stored procedure returning row or resultset

2002-10-14 Thread Heiko Stoermer
Hello, I'm trying to achieve the following with pl/pgsql in postgres 7.2: I need a stored procedure proc() that calculates values for some fields a = f1() b = a + f2() c = b + f3() and returns the tuple (a,b,c) as a rowtype, so that "select proc()" produces a "normal" resultset that can be used