Unix Technical Forum

DELETE causing performance issues

This is a discussion on DELETE causing performance issues within the DB2 forums, part of the Database Server Software category; --> 8.1 FP11 on AIX 5.3. The following DELETE is poorly performing and causing lock escalation (and subsequent deadlock time-outs): ...


Go Back   Unix Technical Forum > Database Server Software > DB2

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 08:17 AM
pike
 
Posts: n/a
Default DELETE causing performance issues

8.1 FP11 on AIX 5.3.

The following DELETE is poorly performing and causing lock escalation
(and subsequent deadlock time-outs):

DELETE FROM submission_log
WHERE subm_id = ?
OR subm_id = (SELECT orig_subm_id FROM submission WHERE subm_id = ?)

Optimizer Plan:

DELETE
( 2)
/------------/ \---\
NLJOIN
Table:
( 3)
/----------------/ \---------------\
SUBMISSION_LOG
FETCH FETCH
( 4) (----)
/ \ /--------/ \
IXSCAN Table: RIDSCN
Table:
( 4) ( 7)

| SUBMISSION /--------/ \--------\
SUBMISSION_LOG
Index: SORT SORT
( 8) ( 10)
PK_SUBMISSION | |
IXSCAN IXSCAN
( 9) ( 11)
/ \ / \
Index: Table: Index: Table:
I_SUBM_LOG_S_A SUBMISSION_LOG I_SUBM_LOG_S_A
SUBMISSION_LOG


Can anyone provide (SQL?) tips other than to increase LOCKTIMEOUT,
LOCKLIST that might improve matters?

Many thanks.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 08:17 AM
Serge Rielau
 
Posts: n/a
Default Re: DELETE causing performance issues

pike wrote:
> 8.1 FP11 on AIX 5.3.
>
> The following DELETE is poorly performing and causing lock escalation
> (and subsequent deadlock time-outs):
>
> DELETE FROM submission_log
> WHERE subm_id = ?
> OR subm_id = (SELECT orig_subm_id FROM submission WHERE subm_id = ?)

OR predicates *shudder*
Try this (note the UNION, NOT UNION ALL)
MERGE INTO submission_log T
USING (SELECT orig_subm_id FROM submission WHERE subm_id = ?
UNION
VALUES (CAST ? AS <whatever>)) S(subm_id)
ON S.subm_id = T.submid
WHEN MATCHED THEN DELETE

If you get lock escalation because you delete so many rows there is
little to be done about that other than breaking down the statement into
chunks.
E.g. deleting 1000 rows at a time or so.

Cheers
Serge

PS: You may want to consider db2set DB2_SKIP_DELETED = yes
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 08:18 AM
Shashi Mannepalli
 
Posts: n/a
Default Re: DELETE causing performance issues

Can u paste the db2exfmt output for this alternative query

DELETE FROM submission_log
> WHERE coalsce(subm_id,subm_id) = ?
> OR subm_id= (SELECT orig_subm_id FROM submission WHERE coalsce(subm_id,subm_id) = ?)


cheers...
Shashi Mannepalli


pike wrote:
> 8.1 FP11 on AIX 5.3.
>
> The following DELETE is poorly performing and causing lock escalation
> (and subsequent deadlock time-outs):
>
> DELETE FROM submission_log
> WHERE subm_id = ?
> OR subm_id = (SELECT orig_subm_id FROM submission WHERE subm_id = ?)
>
> Optimizer Plan:
>
> DELETE
> ( 2)
> /------------/ \---\
> NLJOIN
> Table:
> ( 3)
> /----------------/ \---------------\
> SUBMISSION_LOG
> FETCH FETCH
> ( 4) (----)
> / \ /--------/ \
> IXSCAN Table: RIDSCN
> Table:
> ( 4) ( 7)
>
> | SUBMISSION /--------/ \--------\
> SUBMISSION_LOG
> Index: SORT SORT
> ( 8) ( 10)
> PK_SUBMISSION | |
> IXSCAN IXSCAN
> ( 9) ( 11)
> / \ / \
> Index: Table: Index: Table:
> I_SUBM_LOG_S_A SUBMISSION_LOG I_SUBM_LOG_S_A
> SUBMISSION_LOG
>
>
> Can anyone provide (SQL?) tips other than to increase LOCKTIMEOUT,
> LOCKLIST that might improve matters?
>
> Many thanks.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 08:18 AM
pike
 
Posts: n/a
Default Re: DELETE causing performance issues

Thank you very much Serge - I'll work on those suggestions and come
back to you.

Hi Shashi - the Optimizer Plan is more 'simple', but the associated
cost is much higher for the COALESCE SQL (3232352 timerons v 5790
timerons).

DELETE
( 2)
/------/ \
NLJOIN Table:
( 3) EPO3LINE
/----/ \---\ SUBMISSION_LOG
FETCH IXSCAN
( 4) ( 3)
| / \
IXSCAN Index: Table:
( 4) EPO3LINE EPO3LINE
| I_SUBM_LOG_S_A SUBMISSION_LOG
Index:
EPO3LINE
PK_SUBMISSION

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 08:19 AM
pike
 
Posts: n/a
Default Re: DELETE causing performance issues

Serge - I've been told that the SQL you suggested is not
MAXDB-compatible, therefore currently unacceptable :-( . The developer
is now looking to split the DELETE into two separate statements. Thanks
again for your help.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com