slow SP with temporary tables, any idea of solution? - Mailing list pgsql-hackers

From Pavel Stehule
Subject slow SP with temporary tables, any idea of solution?
Date
Msg-id Pine.LNX.4.44.0502100700530.9430-100000@kix.fsv.cvut.cz
Whole thread Raw
Responses Re: slow SP with temporary tables, any idea of solution?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Hello

I have very slow SP this type:
BEGIN CREATE TEMP TABLE xxx ON COMMIT DROP(); WHILE n > 0 LOOP -- n >> 0   FOR _r IN EXECUTE 'SELECT ...' LOOP
RETURNNEXT _r;     EXECUTE 'UPDATE xxx SET item = 1 WHERE id = '||_r.id;     n := n - 1;   END LOOP; END LOOP;
 
END;

The main problem is too much EXECUTE commands. My first idea wos 
substitute it PREPARED plans. But PREPARED plans are compiled when 
procedure is first time lunched, and I can't easy use it form temp tables. 
I can change PREPARE upd UPDATE item SET .. to EXECUTE 'PREPARE upd 
UPDATE..' and I really saved some time. But this method isn't possible for 
cmd FOR  

I have two possibility solution (before ending successfull solution for SP 
and temporary tables). First, the time for really preparing command will 
be really time of executing PREPARE command. Second, PREPARE can accept 
string parametr like EXECUTE command. But all is inpossible now.

Can you help me other possibilities?
Thank you
Pavel Stehule



pgsql-hackers by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: [SQL] Function .. AS..?
Next
From: prashant sangale
Date:
Subject: about rules