truncate 比 delete 慢
同事過來問我,truncate 比 delete 慢,怎麼回事,我說應該不可能。不過接下來,我眼睛所看到的,卻告訴我,確實如此。
SQL> delete from ac95;
已刪除2行。
已用時間: 00: 00: 00.01
SQL> truncate table ac95;
表被截斷。
已用時間: 00: 01: 32.88
而且不管是你執行truncate 多少次,每次都很慢。用10046跟蹤了下truncate.輸出如下:
truncate table ac95
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.15 82.94 2493 16 9069 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.15 82.95 2493 16 9069 0
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 55
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
reliable message 8 0.00 0.00
enq: RO - fast object reuse 8 0.53 1.38
db file sequential read 2493 0.44 15.95
local write wait 2131 0.39 65.41
rdbms ipc reply 16 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
********************************************************************************
時間主要花費在了local write wait,db file sequential read上面。思考中,希望大家討論討論,怎麼回事。
SQL> delete from ac95;
已刪除2行。
已用時間: 00: 00: 00.01
SQL> truncate table ac95;
表被截斷。
已用時間: 00: 01: 32.88
而且不管是你執行truncate 多少次,每次都很慢。用10046跟蹤了下truncate.輸出如下:
truncate table ac95
call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.15 82.94 2493 16 9069 0
Fetch 0 0.00 0.00 0 0 0 0
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 2 0.15 82.95 2493 16 9069 0
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 55
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
reliable message 8 0.00 0.00
enq: RO - fast object reuse 8 0.53 1.38
db file sequential read 2493 0.44 15.95
local write wait 2131 0.39 65.41
rdbms ipc reply 16 0.00 0.00
SQL*Net message to client 1 0.00 0.00
SQL*Net message from client 1 0.00 0.00
********************************************************************************
時間主要花費在了local write wait,db file sequential read上面。思考中,希望大家討論討論,怎麼回事。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-666582/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- truncate 比 delete 慢的原因。delete
- Truncate,Delete,Drop的比較.delete
- truncate 和 delete 的效能對比delete
- MySQL和Oracle中的delete,truncate對比MySqlOracledelete
- Diffrence Between delete and truncatedelete
- drop、delete 與truncatedelete
- SQL – TRUNCATE vs DELETESQLdelete
- truncate delete drop 區別delete
- truncate delete 的區別delete
- truncate操作巨慢
- 簡述truncate、delete和dropdelete
- truncate與delete的區別delete
- truncate和delete 的區別delete
- SQL truncate 、delete與drop區別SQLdelete
- oracle truncate 與 delete 的區別Oracledelete
- truncate,delete,drop的異同點delete
- delete和truncate刪除的區別delete
- Oracle中truncate和delete的區別Oracledelete
- 深入解析delete和truncate不同之處:delete
- HWM和delete,drop,truncate的關係delete
- truncate,delete,drop的異同點(原)delete
- 關於delete,drop,truncate的問題delete
- 分割槽表truncate慢處理
- 資料庫:drop、truncate、delete的區別資料庫delete
- SQLSERVER 的 truncate 和 delete 有區別嗎?SQLServerdelete
- zt_orafaq_delete與truncate的區別delete
- DELETE 比 SELECT 執行速度慢的測試報告delete測試報告
- Oracle中truncate和delete的區別(例項)Oracledelete
- mv complate重新整理時使用DELETE OR TRUNCATE!delete
- 詳解SQL中drop、delete和truncate的異同SQLdelete
- oracle恢復表delete/truncate/drop的方法總結Oracledelete
- Truncate table 詳解及與delete,drop 的區別delete
- delete/truncate刪除資料索引空間問題delete索引
- Truncate table詳解及與delete,drop的區別delete
- MySQL truncate慢影響系統qps分析MySql
- 資料庫關鍵詞 drop、truncate和delete的用法資料庫delete
- truncate和不帶where子句的delete, 以及drop區別delete
- delete table 和 truncate table - 型別安全的心 - 部落格園delete型別