关于 truncate table 的一点学习札记
---下面整理笔记来之 itpub 的各位前辈的语录。这里做了一个汇总。仅供学习。
truncate table后,oracle会回收表和其表中所在的索引到initial 大小,也就是初始分配的segments大小
truncate和drop一样都是ddl语句, 操作马上生效,原数据不放到rollback segment中,不能回滚
truncate table运行非常慢可能有下面几个原因:
首先要明确truncate table是DDL操作。会重置HWM。
1.查看是不是DML操作锁定了某些记录
2.segment header竞争
truncate 表慢可能跟extent的数量有关系
比方说。你一个表 size 100M,每一个10M ,10个extent
而又一个表 size 50M ,每一个8K,6400个extent
那么,第二个表的truncate就会比第一个慢上好多
通常来说是因为extent 太多,truncate时在做回收extent的动作
这也是 local management比 dictionary management好的当中一点。
假设操心下次碰到相同问题
能够考虑使用
truncate table test reuse STORAGE 的语句,能够避免hung在回收extent上。
就要用到 分次回收 的方式了
比方说。100M的表,每次回收 20M,在感觉上可能好点。
truncate table t4 reuse STORAGE ;
alter table test_tun deallocate unused keep 80M;
alter table test_tun deallocate unused keep 60M;
alter table test_tun deallocate unused keep 40M;
alter table test_tun deallocate unused keep 20M;
truncate table test_tun drop storage;
假设truncate table 很慢 ,能够依照下面方法来诊断:
1.请查询 对应的session 在 v$session_wait 视图中的等待事件
2.能够用oradebug hanganalyze分析系统挂起的原因
3.假设为了试验目的。更能够做个10046 level 8的event
###################
### BUG lists
###################
truncate的时候,dbwr占用cpu高不高?能够试一下以下文档中的workround (alter system flush buffer_cache; 后再truncate),假设生效应该就是了。你能够升到10.2.0.4.3
是不是这个bug不好说,假设日志的大小不足导致日志切换hang住,引起dbwr的等待,出现不少free buffer busy的等待,而truncate又要做checkpoint,所以这时候前台进程也要等待dbwr,导致enqueue RO的wait变长
---------------------------------------------
Bug 8544896 Waits for "enq: RO - fast object reuse" with high DBWR CPU
This note gives a brief overview of bug 8544896.
The content was last updated on: 08-JAN-2010
Click here for details of each of the sections below.
Affects:
Product (Component) Oracle Server (Rdbms)
Range of versions believed to be affected Versions >= 10.2.0.4
Versions confirmed as being affected 10.2.0.4
Platforms affected Generic (all / most platforms affected)
It is believed to be a regression in default behaviour thus:
Regression introduced in 10.2.0.4
Fixed:
This issue is fixed in 10.2.0.4.3 (Patch Set Update)
Symptoms: Related To:
Performance Affected (General)
Performance Of Certain Operations Affected
Waits for "enq: RO - fast object reuse"
Truncate
_DB_FAST_OBJ_TRUNCATE
Description
This problem is introduced in 10.2.0.4.
Sessions can wait on "enq: RO - fast object reuse" while DBWR consumes
lots of CPU when performing truncate type operations.
Workaround
Flush the buffer cache before truncating
OR
set _db_fast_obj_truncate = FALSE.
Please note: The above is a summary description only. Actual symptoms can vary. Matching to any symptoms here does not confirm that you are encountering this problem. Always consult with Oracle Support for advice.
References
Bug:8544896 (This link will only work for PUBLISHED bugs)
Note:245840.1 Information on the sections in this article
关于 truncate table 的一点学习札记的更多相关文章
- MySQL学习笔记:delete from与truncate table的区别
在Mysql数据库的使用过程中,删除表数据可以通过以下2种方式: delete from table_name truncate table table_name (1)delete from语句可以 ...
- MySQL DELETE语句和TRUNCATE TABLE语句的区别
MySQL DELETE语句和TRUNCATE TABLE语句的区别 2010-10-08 16:05 佚名 互联网 字号:T | T 在MySQL数据库中,DELETE语句和TRUNCATE TAB ...
- SQL菜鸟学习札记(二)
五月份一直在写SQL,之后写了一个期末大作业的项目,现在才有时间把之前遇到的各种奇怪的问题整理出来.下一部分札记应该是大作业中使用到的SQL的整理. 一.UPDATE SET语句后面可以并列赋值. 之 ...
- [20180630]truncate table的另类恢复2.txt
[20180630]truncate table的另类恢复2.txt --//上个星期做了truncate table的另类恢复,通过修改数据块的段号,再通过rowid定位收集数据,达到修复的目的.- ...
- [20180627]truncate table的另类恢复.txt
[20180627]truncate table的另类恢复.txt --//前几天看链接http://www.xifenfei.com/2018/06/truncate-table-recovery. ...
- mysql 删除表记录 delete和truncate table区别
MySQL中删除表记录delete from和truncate table的用法区别: mysql中有两种删除表中记录的方法: (1)delete from语句, (2)truncate table语 ...
- SQL Server 2008 R2——TRUNCATE TABLE 无法截断表 该表正由 FOREIGN KEY 约束引用
=================================版权声明================================= 版权声明:原创文章 禁止转载 请通过右侧公告中的“联系邮 ...
- SQLite - TRUNCATE TABLE
https://www.tutorialspoint.com/sqlite/sqlite_truncate_table.htm Unfortunately, no TRUNCATE TABLE in ...
- TRUNCATE TABLE (Transact-SQL)
删除表中的所有行,而不记录单个行删除操作. TRUNCATE TABLE 与没有 WHERE 子句的 DELETE 语句类似:但是,TRUNCATE TABLE 速度更快,使用的系统资源和事务日志资源 ...
随机推荐
- zoj 2104 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2 Seconds Memory Limit: 65536 KB Contest time again! How excit ...
- IndiaHacks 2nd Elimination 2017 (unofficial, unrated mirror, ICPC rules)
D. Airplane Arrangements time limit per test 2 seconds memory limit per test 256 megabytes input sta ...
- 在windows下安装flex和bison、GCC
学习Stellar-core 需要依赖项flex .bison .gcc三个依赖项 下载得网址:链接: https://pan.baidu.com/s/1mitCLcs 密码: 3jaj 通过 w ...
- BZOJ 3566 [SHOI2014]概率充电器 ——期望DP
期望DP. 补集转化,考虑不能被点亮的情况, 然后就是三种情况,自己不能亮,父亲不能点亮它,儿子不能点亮它. 第一次计算比较容易,第二次计算的时候需要出去第一次的影响,因为一条线只能传导一次 #inc ...
- leetcode 319 灯泡问题
例子:1-9 1的因子1 2 1,2 3 1,,3 4 1,2,4 5 1,5 6 1,2,3,6 7 1,7 8 ...
- codeblocks 中文编码问题
参考文章: code::blocks 初使用遇到的问题记录 codeblocks 中文编码问题 string var="汉"; cout<<var<<end ...
- jmeter监控linux cpu 内存 网络 IO
下载地址:http://jmeter-plugins.org/downloads/all/ PerfMon: 用来监控Server的CPU.I/O.Memory等情况 ServerAgent-2.2. ...
- 小机房的树(codevs 2370)
题目描述 Description 小机房有棵焕狗种的树,树上有N个节点,节点标号为0到N-1,有两只虫子名叫飘狗和大吉狗,分居在两个不同的节点上.有一天,他们想爬到一个节点上去搞基,但是作为两只虫子, ...
- 启动第一个 KVM 虚机
本节演示如何使用 virt-manager 启动 KVM 虚机. 首先通过命令 virt-manager 启动图形界面 1 # virt-manager 点上面的图标创建虚机 给虚机命名为 kvm1, ...
- msp430入门学习43
msp430的其他十一 msp430入门学习