473,386 Members | 1,610 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Performance for deleting multiple records

Looking for tips on how to improve performance on deleting records.
In our database we do dataloads daily that require us to purge
millions of records a day so any improvement in speed would be
welcomed.
CREATE OR REPLACE PROCEDURE ETL_CUSTATTRIB_STGTOTRG_ALT1v2 AS
TYPE cust_t IS TABLE OF customer_master.customer_id%TYPE
INDEX BY BINARY_INTEGER;
TYPE attrib_t IS TABLE OF attribute_master.attribute_id%TYPE
INDEX BY BINARY_INTEGER;
attrib_id attrib_t;
cust_id cust_t;
i INTEGER;
insertCount INTEGER := 0;
recordCount INTEGER := 0;
msg VARCHAR(512);
startTime DATE;
endTime Date;
totalTime NUMBER;
msg_err VARCHAR(40);
hrs NUMBER;
mins NUMBER;
secs NUMBER;
cursor etl_cust_att_c1 is
select /*+ USE_HASH(customer_master, etl_cust_attributes) */
cm.customer_id, am.attribute_id
from attribute_master am, etl_cust_attributes eca, customer_master
cm
where eca.alt_customer_id = cm.alt_customer_id
and am.name = eca.attribute_name
order by cm.customer_id;
begin
SELECT SYSDATE INTO startTime FROM DUAL;
OPEN etl_cust_att_c1;
LOOP
EXIT WHEN etl_cust_att_c1%NOTFOUND;
COMMIT;
FETCH etl_cust_att_c1 BULK COLLECT INTO cust_id, attrib_id LIMIT
5000;

FORALL i IN 1..cust_id.COUNT
delete from cust_attributes_old where customer_id = cust_id(i) and
attribute_id = attrib_id(i);

insertCount := insertCount + SQL%ROWCOUNT;
recordCount := recordCount + cust_id.COUNT;

END LOOP;
COMMIT;
SELECT SYSDATE INTO endTime FROM DUAL;
totalTime := (endTime - startTime);
hrs := totalTime*24;
mins := (hrs-FLOOR(hrs))*60;
secs := (mins-FLOOR(mins))*60;
msg := utl_tcp.crlf ||'Total Rows Loaded = '||recordCount||
utl_tcp.crlf ||'Total Rows Deleted = '||insertCount||
utl_tcp.crlf ||'Session Start Time = '||TO_CHAR(startTime,'DAY
MON DD HH24:MI:SS YYYY')||
utl_tcp.crlf ||'Session Completion Time =
'||TO_CHAR(endTime,'DAY MON DD HH24:MI:SS YYYY')||
utl_tcp.crlf ||'Session Elapsed Time = '||FLOOR(hrs)||':'||
FLOOR(mins)||':'||FLOOR(secs)||' (H:M:S)'||
utl_tcp.crlf ||utl_tcp.crlf ||'Table Details:
CUST_ATTRIBUTES'||
utl_tcp.crlf ||'Rows Deleted Delete Throughput'||
utl_tcp.crlf ||'------------- -------------------'||
utl_tcp.crlf
||insertCount||' '||ROUND(insertCount/((endTime-startTime)*86400));
send_mail('Oracle ETL','r*******@household.com;','CUST_ATTRIBUTES
ALTI COMPLETED',msg,msg_err);
DBMS_OUTPUT.PUT_LINE('TOTAL ROWS DELETED = '||insertCount);
DBMS_OUTPUT.PUT_LINE('TOTAL ROWS LOADED= '||recordCount);
CLOSE etl_cust_att_c1;
end;
Jul 19 '05 #1
1 7829
Delete millions of records a day... This is a recipe for really,
really slow performance. And that's not just slow for your particular
delete job but potentially for your whole system as well.

There must be a better way to "remove" all those rows. Have you
considered partitioning?

rr******@hotmail.com (rishi) wrote in message news:<c4*************************@posting.google.c om>...
Looking for tips on how to improve performance on deleting records.
In our database we do dataloads daily that require us to purge
millions of records a day so any improvement in speed would be
welcomed.
CREATE OR REPLACE PROCEDURE ETL_CUSTATTRIB_STGTOTRG_ALT1v2 AS
TYPE cust_t IS TABLE OF customer_master.customer_id%TYPE
INDEX BY BINARY_INTEGER;
TYPE attrib_t IS TABLE OF attribute_master.attribute_id%TYPE
INDEX BY BINARY_INTEGER;
attrib_id attrib_t;
cust_id cust_t;
i INTEGER;
insertCount INTEGER := 0;
recordCount INTEGER := 0;
msg VARCHAR(512);
startTime DATE;
endTime Date;
totalTime NUMBER;
msg_err VARCHAR(40);
hrs NUMBER;
mins NUMBER;
secs NUMBER;
cursor etl_cust_att_c1 is
select /*+ USE_HASH(customer_master, etl_cust_attributes) */
cm.customer_id, am.attribute_id
from attribute_master am, etl_cust_attributes eca, customer_master
cm
where eca.alt_customer_id = cm.alt_customer_id
and am.name = eca.attribute_name
order by cm.customer_id;
begin
SELECT SYSDATE INTO startTime FROM DUAL;
OPEN etl_cust_att_c1;
LOOP
EXIT WHEN etl_cust_att_c1%NOTFOUND;
COMMIT;
FETCH etl_cust_att_c1 BULK COLLECT INTO cust_id, attrib_id LIMIT
5000;

FORALL i IN 1..cust_id.COUNT
delete from cust_attributes_old where customer_id = cust_id(i) and
attribute_id = attrib_id(i);

insertCount := insertCount + SQL%ROWCOUNT;
recordCount := recordCount + cust_id.COUNT;

END LOOP;
COMMIT;
SELECT SYSDATE INTO endTime FROM DUAL;
totalTime := (endTime - startTime);
hrs := totalTime*24;
mins := (hrs-FLOOR(hrs))*60;
secs := (mins-FLOOR(mins))*60;
msg := utl_tcp.crlf ||'Total Rows Loaded = '||recordCount||
utl_tcp.crlf ||'Total Rows Deleted = '||insertCount||
utl_tcp.crlf ||'Session Start Time = '||TO_CHAR(startTime,'DAY
MON DD HH24:MI:SS YYYY')||
utl_tcp.crlf ||'Session Completion Time =
'||TO_CHAR(endTime,'DAY MON DD HH24:MI:SS YYYY')||
utl_tcp.crlf ||'Session Elapsed Time = '||FLOOR(hrs)||':'||
FLOOR(mins)||':'||FLOOR(secs)||' (H:M:S)'||
utl_tcp.crlf ||utl_tcp.crlf ||'Table Details:
CUST_ATTRIBUTES'||
utl_tcp.crlf ||'Rows Deleted Delete Throughput'||
utl_tcp.crlf ||'------------- -------------------'||
utl_tcp.crlf
||insertCount||' '||ROUND(insertCount/((endTime-startTime)*86400));
send_mail('Oracle ETL','r*******@household.com;','CUST_ATTRIBUTES
ALTI COMPLETED',msg,msg_err);
DBMS_OUTPUT.PUT_LINE('TOTAL ROWS DELETED = '||insertCount);
DBMS_OUTPUT.PUT_LINE('TOTAL ROWS LOADED= '||recordCount);
CLOSE etl_cust_att_c1;
end;

Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: John | last post by:
Hi All, I have two backend databases that area link to a frontend database where information is entered, retrieved and deleted. The information accessed from the frontend database is coming from...
13
by: Bob Darlington | last post by:
I have a repair and backup database routine which runs when a user closes down my application. It works fine in my development machine, but breaks on a client's at the following line: If...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
4
by: Vadivel Kumar | last post by:
Hi Guys, I have a doubt which is little bit conceptual rather than a coding convention. I have a a table called products in which I have 40000 and odd products which is expected to be...
8
by: shumaker | last post by:
I'm wondering if adding an autonumber primary key will improve the performance of a multiuser access database on a network share. I have a website that lists many tips for improving performance of...
8
by: NAdir | last post by:
Hi, thank you for your help. My VB.Net application contains a document that the user can refresh at any time. The refresh works fine and needs to loop through few datatables (hundreds of rows)....
11
by: shriil | last post by:
Hi I have this database that calculates and stores the incentive amount earned by employees of a particular department. Each record is entered by entering the Date, Shift (morn, eve, or night)...
3
by: bharadwajrv | last post by:
Hi... i need to know which approach is good in-terms of performance while deleting the records from two tables... Here is my table struct: Master table (table1)...
2
by: padmaneha | last post by:
Hi I have created two tables 'TrainsMaster' & 'TransArrvlDepinfo' Columns which I have created in 'TrainsMaster' are 'trainName,TrainNo, StartStaionId, & EndstationId' Columns which I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.