Delete stmt taking so much time [message #514949] |
Thu, 07 July 2011 08:03 |
|
shyamu544
Messages: 10 Registered: July 2011
|
Junior Member |
|
|
Hi Team,
I'm deleteing a table which has 6118884 rows .
Following delete stmt I'm using it
Delete from dfn_dw_sales_fact dw WHERE dfn_source_system_id = 4;
It will deelete 108140 rows.
For excuting this delete stmt taking 30 mins.
Is there any possible way to tune this one ?
(Since this delete i'm using in one my stored procedure)
Please advise me.
FYI:
I had created index on dfn_dw_sales_fact.dfn_source_system_id (but no use) and there is no referncial constaraints also on this table.
Please advise me and appricate your early response.
Thanks,
Shyamu.A
|
|
|
|
|
|
Re: Delete stmt taking so much time [message #514955 is a reply to message #514953] |
Thu, 07 July 2011 08:14 |
cookiemonster
Messages: 13959 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Explain plans should be got in sqlplus like this:
SQL> explain plan for select * from dual;
Explained.
SQL> select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
Plan hash value: 3543395131
--------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 2 | 2 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| DUAL | 1 | 2 | 2 (0)| 00:00:01 |
--------------------------------------------------------------------------
8 rows selected.
SQL>
|
|
|
|
|
|
|
|
|
|
|
|
Re: Delete stmt taking so much time [message #514965 is a reply to message #514951] |
Thu, 07 July 2011 08:24 |
cookiemonster
Messages: 13959 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
cookiemonster wrote on Thu, 07 July 2011 14:061) Post an explain plan for the delete
2) Post DLL for table and all indexes
3) Trace the delete statement and see where the time is being spent.
|
|
|
|
Re: Delete stmt taking so much time [message #514967 is a reply to message #514963] |
Thu, 07 July 2011 08:26 |
cookiemonster
Messages: 13959 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Roachcoach wrote on Thu, 07 July 2011 14:20It could just be a massive table and it's the undo generation killing it and/or no indexes
More likely to be too many indexes than no indexes every index has to be modified for each row deleted and the numbers involved suggest full table scan.
|
|
|
|
|
|
|
|
|
Re: Delete stmt taking so much time [message #514976 is a reply to message #514975] |
Thu, 07 July 2011 09:28 |
cookiemonster
Messages: 13959 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I bet if you analyze the table it'll start using the index without the hint.
You should really upgrade to 10g or 11g since:
1) They are actually still supported by oracle, unlike 8i which has been out of support for years.
2) The CBO works better.
3) Oracle automatically gathers stats for you.
And next time you post a question tell us what version you are using at the start - it does make a difference.
|
|
|
|
|
|
|
|