Stef <svb@ucs.co.za> writes:
> I've been dealing with a problem for the past two days
> where a certain sql statement works 2 out of 5 times, and
> the other 3 times, it causes the machine (quad Xeon 2.8GHz
> + 792543232 bytes mem, linux kernel 2.4.26-custom, pg ver 7.3.4)
> to slow down, and finally grind to a halt.
IIRC, PG prior to 7.4 had some problems with memory leaks in repeated
execution of SQL-language functions ... and your query sure looks like
it's going to be doing a lot of repeated execution of those functions.
Please try it on 7.4.2 and see if you still have a problem.
It seems somewhat interesting that you see the problem only sometimes
and not every time, but there's not much point in investigating further
if it turns out the problem is already fixed.
regards, tom lane