dbTalk Databases Forums  

the performance of delete with commitcount routine

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss the performance of delete with commitcount routine in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default the performance of delete with commitcount routine - 05-24-2006 , 09:21 PM






i see in this forum to make this routine using

"DELETE FROM (SELECT 1 FROM <name> WHERE <condition> FETCH FIRST <n>
ROWS
ONLY)
Prepare this one ONCE then EXECUTE in the loop. "

it works .

but now i find it's a bad performance when the data is scattering and
no suitable index is defined.

i think the reason is it will make a tablescan for each loop .

in these case i use another procedure which use a cursor to fetch rows
, so it only perform one table scan .

but the problem is : i have to define a static cursor for each table I
want to delete . 'cause it note that " the curcor XXX is not define"
in running time , after i create the cursor dynamicly with a string and
compile it well . it's so weird .


Reply With Quote
  #2  
Old   
Serge Rielau
 
Posts: n/a

Default Re: the performance of delete with commitcount routine - 05-25-2006 , 05:00 AM






heming_g (AT) hotmail (DOT) com wrote:
Quote:
i see in this forum to make this routine using

"DELETE FROM (SELECT 1 FROM <name> WHERE <condition> FETCH FIRST <n
ROWS
ONLY)
Prepare this one ONCE then EXECUTE in the loop. "

it works .

but now i find it's a bad performance when the data is scattering and
no suitable index is defined.

i think the reason is it will make a tablescan for each loop .
Your are correct in your analysis. It's not the silver bullet.

Quote:
in these case i use another procedure which use a cursor to fetch rows
, so it only perform one table scan .

but the problem is : i have to define a static cursor for each table I
want to delete . 'cause it note that " the curcor XXX is not define"
in running time , after i create the cursor dynamicly with a string and
compile it well . it's so weird .
Something like that should do...

CREATE PROCEDURE ....
BEGIN
DECLARE txt VARCHAR(100);
DECLARE stmt STATEMENT;
DECLARE cur CURSOR FOR stmt;
SET txt = 'SELECT 1 FROM .... FOR UPDATE';
PREPARE stm FROM txt;
OPEN cur;
....
END


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.