Home » RDBMS Server » Performance Tuning » Delete command running taking long time (windows server 2003, oracle 11g DB)
Delete command running taking long time [message #494052] Fri, 11 February 2011 03:13 Go to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

I am trying to delete rows from a table and its is running from long time (more than 4 hours till the time of post). When I inserted these same number of rows from this table to another table it just taken 20-25 min.

After scratching the net I am checking the undo usage and its continuously increase the used undo blocks. can some one tell me why this query is taking so much time? or what I can do other than waiting to complete this query.

=============================================================
SQL> insert into backup.Tbl_chat_log select * from smschat.Tbl_chat_log where tr
unc(DATE_TIME) <= trunc(sysdate-7);

13008144 rows created.

SQL> commit;

Commit complete.

SQL> delete from smschat.Tbl_chat_log where trunc(DATE_TIME) <= trunc(sysdate-7);
=====================================================

There is only one index on this table.

INDEX_NAME COLUMN_NAME
------------------------------ --------------------
IDXAPRT_DTIME APARTY
IDXAPRT_DTIME SYS_NC00007$


Regards

Pradeep
Re: Delete command running taking long time [message #494054 is a reply to message #494052] Fri, 11 February 2011 03:17 Go to previous messageGo to next message
knight
Messages: 111
Registered: January 2009
Senior Member
how many records you want to delete?
how many total records are there in this table?
Re: Delete command running taking long time [message #494056 is a reply to message #494052] Fri, 11 February 2011 03:21 Go to previous messageGo to next message
Michel Cadot
Messages: 68648
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Insert takes less time because you have few rollback to manage when you have many when you delete.
Nothing strange in what you have.
In addition, have you triggers and indexes on the table?

Regards
Michel
Re: Delete command running taking long time [message #494059 is a reply to message #494056] Fri, 11 February 2011 03:24 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

As I am deleting the same range of record which I Inserted to another table i.e. 13008144 and the total number of records is 14341141.

There is no trigger on the base table TBL_CHAT_LOG.

Regards
Pradeep


[Updated on: Fri, 11 February 2011 03:26] by Moderator

Report message to a moderator

Re: Delete command running taking long time [message #494061 is a reply to message #494059] Fri, 11 February 2011 03:28 Go to previous messageGo to next message
Michel Cadot
Messages: 68648
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
13008144 and the total number of records is 14341141.

In this case, it far faster to move the rows you want to keep in a temp table, truncate the table and move back the rows you first move.
It will be at least 10 times faster.

Regards
Michel
Re: Delete command running taking long time [message #494063 is a reply to message #494061] Fri, 11 February 2011 03:36 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

We know that this can be done but I can't do the same because there is transaction on the data after the date spacified must be going on and I can't truncate table table right now.

Is there any other solution or any other suggestation except this.


Thanx & Regards

pradeep
Re: Delete command running taking long time [message #494064 is a reply to message #494063] Fri, 11 February 2011 03:49 Go to previous messageGo to next message
knight
Messages: 111
Registered: January 2009
Senior Member
Quote:
It will be at least 10 times faster.

Quote:
its is running from long time (more than 4 hours till the time of post).

no,you have to weigh your options
did you consider partitioning this table?
Re: Delete command running taking long time [message #494066 is a reply to message #494064] Fri, 11 February 2011 03:59 Go to previous messageGo to next message
pradies
Messages: 250
Registered: May 2008
Senior Member
Hi,

It means I will have to wait til the time this completed. whenever it will be completed.

ragards

Pradeep
Re: Delete command running taking long time [message #494068 is a reply to message #494066] Fri, 11 February 2011 04:19 Go to previous messageGo to next message
Michel Cadot
Messages: 68648
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes.

Regards
Michel
Re: Delete command running taking long time [message #494088 is a reply to message #494052] Fri, 11 February 2011 05:33 Go to previous message
OraKaran
Messages: 183
Registered: March 2008
Location: United Kingdom
Senior Member
Hello pradies

By any chance do you have constraints on this table with 'delete cascade' effect?

In 9i I observed such scenario where child table did not had index on the column was was being fully scanned for each row deleted from parent table.

Regards,
OraKaran
Previous Topic: Application is slow when no of connections goes up
Next Topic: Queries on PGA Settings and related Memory Management
Goto Forum:
  


Current Time: Sun May 05 05:46:06 CDT 2024