关于 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 速度更快,使用的系统资源和事务日志资源 ...
随机推荐
- swift final关键字、?、!可选与非可选符
?符号: 可选型 在初始化时可以赋值为nil !符号: 隐形可选型 类型值不能为nil,如果解包后的可选类型为nil会报运行时错误,主要用在一个变量/常量在定义瞬间完成之后值一定会存在的情况.这主要 ...
- 【转】SQL索引一步到位
原文:http://www.cnblogs.com/AK2012/archive/2013/01/04/2844283.html SQL索引一步到位(此文章为“数据库性能优化二:数据库表优化”附属文章 ...
- 用ajax异步请求一个块
使用用户控件,作为一个块,生成一段独立的html. 请求一个一般应用程序,在一般应用程序中加载读取用户控件,并给用户控件传值. Page page = new Page(); ...
- 九度oj 题目1209:最小邮票数
题目描述: 有若干张邮票,要求从中选取最少的邮票张数凑成一个给定的总值. 如,有1分,3分,3分,3分,4分五张邮票,要求凑成10分,则使用3张邮票:3分.3分.4分即可. 输入: 有多组数据, ...
- BZOJ 1933 [Shoi2007]Bookcase 书柜的尺寸 ——动态规划
状态设计的方法很巧妙,六个值 h1,h2,h3,t1,t2,t3,我们发现t1,t2,t3可以通过前缀和优化掉一维. 然后考虑把h留下还是t留下,如果留下h显然t是会发生改变的,一个int存不下. 如 ...
- BZOJ 1072 [SCOI2007]排列perm ——状压DP
[题目分析] 没什么好说的,水题. 代码比较丑,结果需要开long long 时间爆炸 [代码] #include <cstdio> #include <cstring> #i ...
- 品酒大会 BZOJ 4199
品酒大会 [问题描述] [输入格式] [输出格式] [样例输入] 10ponoiiipoi 2 1 4 7 4 8 3 6 4 7 [样例输出] 45 56 10 56 3 32 0 0 0 0 0 ...
- 玩转css样式选择器----当父元素有多个子元素时选中第一个
- 求菲波那契数列的第n个数
1,2,3,5,8,13..... 求第n个数 def get_num(n): if n == 1: return 1 if n == 2: return 2 return get_num(n - 1 ...
- wiki平台工具
1. confluence 评点: 好用,与world类似.模板多.