Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-13 Thread Merlin Moncure
> I will try separate my huge data computation into several pieces > something like: [...] > If I understood correctly, "begin ... exception when .. then ... end" > can work the same way as commit. In another way, if commands in the > sub-block (such as step1) run successfully, data in this part (

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-13 Thread Emi Lu
Hi Merlin, >> In general, if you have the choice between looping over a large result >> in a stored procedure (or, even worse, in a client app) and letting the >> backend do the looping, then letting the backend handle it is nearly >> always >> faster. There are different reasons why a la

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-13 Thread Merlin Moncure
> >> In general, if you have the choice between looping over a large result > >> in a stored procedure (or, even worse, in a client app) and letting the > >> backend do the looping, then letting the backend handle it is nearly > >> always > >> faster. There are different reasons why a large q

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-11 Thread Florian G. Pflug
Emi Lu wrote: >> Florian G. Pflug wrote: >> < snipped code of stored procedure > Are you aware of the "insert into (, ..., ) select , .., from " command? It'd be much faster to use that it it's possible... >>> >>> It did faster. Thank you Florian. Could you hint me why "i

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Florian G. Pflug
Emi Lu wrote: Florian G. Pflug wrote: < snipped code of stored procedure > Are you aware of the "insert into (, ..., ) select , .., from " command? It'd be much faster to use that it it's possible... greetings, Florian Pflug It did faster. Thank you Florian. Could you hint me why "i

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Emi Lu
Florian G. Pflug wrote: < snipped code of stored procedure > Are you aware of the "insert into (, ..., ) select , .., from " command? It'd be much faster to use that it it's possible... greetings, Florian Pflug It did faster. Thank you Florian. Could you hint me why "insert into

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Emi Lu
Florian G. Pflug wrote: Emi Lu wrote: The example I have is: CREATE OR REPLACE function test() returns boolean AS $$ DECLARE ... ... counterINTEGER := 0; BEGIN ... ... query_value := ' .' ; OPEN curs1 FOR EXECUTE query_value; LOOP FETCH curs1 INTO studid;

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Florian G. Pflug
Emi Lu wrote: The example I have is: CREATE OR REPLACE function test() returns boolean AS $$ DECLARE ... ... counterINTEGER := 0; BEGIN ... ... query_value := ' .' ; OPEN curs1 FOR EXECUTE query_value; LOOP FETCH curs1 INTO studid; EXIT WHEN NOT FOUND;

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Emi Lu
I got the answer. Although the compile passed, when it reaches 5000, the commit command causes a "SPI_ERROR_TRANSACTION" exception. Thank you for all your hint. You can't do commits inside of a function. The example I have is: CREATE OR REPLACE function test() returns boolean AS $$ DECLAR

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Emi Lu
Hi Bruno, You can't do commits inside of a function. The example I have is: CREATE OR REPLACE function test() returns boolean AS $$ DECLARE ... ... counterINTEGER := 0; BEGIN ... ... query_value := ' .' ; OPEN curs1 FOR EXECUTE query_value; LOOP FETCH curs1 I

Re: [GENERAL] in Pl/PgSQL, do commit every 5000 records

2006-03-10 Thread Bruno Wolff III
On Fri, Mar 10, 2006 at 09:36:16 -0500, Emi Lu <[EMAIL PROTECTED]> wrote: > Good morning, > > In a plpgsql function, I am trying to insert 900, 000 records into > several tables. I remembered people mentioned before that it is better > and more efficient to commit actions for let's say every 5