vishal saberwal <vishalsaberwal@xxxxxxxxx> writes: > The query I am actually trying to optimize is long and has a few joins (for= > =20 > normalization) and hence didn't copy it here. > The function structure is similar to the one above. > (a) Am i right in thinking that if I eliminate the for loop, some=20 > performance gain can be achieved? > (b) Is there a way to eliminate this for loop? Is the plpgsql layer actually doing anything useful, or just passing back the results of the SQL command? If the latter, use a SQL function instead. Or perhaps even better, replace the function by a view. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster