Janning Vygen <vygen@xxxxxx> writes: > this way it works: > CREATE TEMP TABLE ranking AS *Q*; > EXECUTE 'UPDATE temp_gc SET gc_rank = ranking.rank > FROM ranking WHERE temp_gc.mg_name = ranking.mg_name;'; > and this way it doesn't: > UPDATE temp_gc > SET gc_rank = ranking.rank > FROM (*Q*) > ranking > WHERE temp_gc.mg_name = ranking.mg_name; It's difficult to be sure without looking at EXPLAIN output, but I would guess that the second query is being done with a plan that involves multiple scans of "*Q*", and that's confusing your function. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 4: Have you searched our list archives? http://archives.postgresql.org