| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

08-23-11, 14:13
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
|
|
|
deleting large number of rows in a table that has 20 child tables
|
|
Hi there,
Thanks to forum for everything.
I have a problem here for ur valuable response,
I have a table with almost one million rows, the table has 21 child tables. I need to delete two lac rows from the master table. Is there any solution, so that I dont face any transaction log full error???
thank you.
|
|

08-23-11, 14:17
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Write a stored procedure with a cursor on the main parent table, and then commit after each logical unit of work (which includes deleting all the child tables for a parent). You will need to define the cursor WITH HOLD so it will not close when you do a commit.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

08-24-11, 14:02
|
|
Registered User
|
|
Join Date: Aug 2011
Posts: 9
|
|
|
|
Quote:
Originally Posted by Marcus_A
Write a stored procedure with a cursor on the main parent table, and then commit after each logical unit of work (which includes deleting all the child tables for a parent). You will need to define the cursor WITH HOLD so it will not close when you do a commit.
|
thank you, but can u plz elaborate it?
|
|

08-24-11, 21:38
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
Originally Posted by jagdis_vishnu
thank you, but can u plz elaborate it?
|
Actaully writing such a stored procedure is a fee-based activity IMO. If you or your company are interested, then send me a private message.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

08-25-11, 01:46
|
|
Super Moderator
|
|
Join Date: Aug 2001
Location: UK
Posts: 4,534
|
|
Try using the search button. This question has been asked and answered dozens of times. If you search hard enough you will find an example.
If you have difficulties when creating stored procedure, come back to the forum.
Or, of course you have the option to PM Marcus.
|
|

08-25-11, 02:07
|
|
Registered User
|
|
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
|
|
that is really a good idea ..
...is a fee-based activity IMO. If you or your company are interested, then send me a private message..
I will use it a lot in the future.. in this forum anyhow..
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
|
|

08-25-11, 02:10
|
|
Super Moderator
|
|
Join Date: Aug 2001
Location: UK
Posts: 4,534
|
|
Quote:
Originally Posted by sathyaram_s
Or, of course you have the option to PM Marcus.
|
..... or Guy 
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
|
|

08-25-11, 06:56
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
I will also provide forum searches for people (on a fee basis) for those who don't have time to do it themselves.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

08-25-11, 07:05
|
|
Registered User
|
|
Join Date: Apr 2008
Posts: 9
|
|
If it is a one time job .. then this could be a idea. Select rows in chunks
and delete them again and again.
delete form (select * from table name fetch first 15000 rows only).
you can right a small shell script also.
Thanks
Naval K 
|
|

08-25-11, 08:06
|
|
Registered User
|
|
Join Date: May 2003
Location: USA
Posts: 5,196
|
|
Quote:
Originally Posted by Naval29
If it is a one time job .. then this could be a idea. Select rows in chunks
and delete them again and again.
delete form (select * from table name fetch first 15000 rows only).
you can right a small shell script also.
Thanks
Naval K 
|
The reason why I recommended a stored procedure is that the OP said there was one parent table with 21 child tables, and I assume that the logical UOW integrety needs to be maintained. A properly written SP will also have the following additional advantages:
- not filling up the transaction log since there would be intermediate commits at the logical UOW level
- doing intermediate commits reduces lock contention during the deletes, since only those rows deleted since the last commit point will be locked
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
|
|

08-28-11, 11:20
|
|
Registered User
|
|
Join Date: Sep 2008
Location: Toronto,Canada
Posts: 606
|
|
Quote:
Originally Posted by Naval29
If it is a one time job .. then this could be a idea. Select rows in chunks
and delete them again and again.
delete form (select * from table name fetch first 15000 rows only).
you can right a small shell script also.
Thanks
Naval K 
|
This is second best option to SP. I had used it for all one time jobs. Some daily jobs run via SP.
Make sure the chunk is small enough to let the database keep going easy.
One of my prune job using shell script took 11 hours on a very busy gaming database.
A template SP can be provided if needed !!
Regards
DBFinder
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|