观察drop partition时的锁情况
借一次drop partition机会,观察下相关表及分区的锁情况。
由于表较大,便于观察,作个简单的记录,供以后参考(相关表名等信息略作更改):
借一次drop partition机会,观察下相关表及分区的锁情况。
由于表较大,便于观察,作个简单的记录,供以后参考(相关表名等信息略作更改):
记得刚刚当DBA时,查询了一下v$lock视图,做了个group by:
SYS@DB1> select type,count(*) from v$lock 2 group by type order by 2 desc; TYPE COUNT(*) ---- ---------- MR 1193 TM 83 TX 14 RT 3 TS 2 XR 2 DM 1 PI 1 |
发现大量的“MR”锁,赶紧上报说:数据库有问题啊,大量MR锁。哈哈,闹了个小笑话。
10G中,当数据库无法连接,又需要做SYSTEM DUMP时,可以尝试使用sqlplus的prelim选项
在DBA测试用的数据库中,查询dba_data_files报了以下错误:
SYS@TADBA> select * from dba_data_files; select * from dba_data_files * ERROR 位于第 1 行: ORA-00379: no free buffers available in buffer pool DEFAULT for block size 16K |
从报错来看,应该是创建了16K的表空间,又没有分配db_16k_cache_size的原因。
在9I中,可以创建不同block size的表空间,而这些表空间也要分配相应的db_nk_cache才行。
在Unix操作系统上,Oracle创建TEMP表空间,添加TEMP文件时,可以观察到瞬间就完成了,而且文件系统的使用率又没增长多少。这其实就是因为TEMP文件是Sparse Files的原因。
什么是Sparse Files
On many Unix filesystems, files containing long strings of nulls can be stored
much more efficiently than other files. To be specific, if a string of nulls
spans an entire allocation block, that whole block is not stored on disk at all.
Files where one or more blocks are omitted in this way are called sparse files.
The missing blocks are also known as holes.
对于主键约束与唯一性约束:
在9I中,当索引为唯一索引时,Disable constraint时,同时会把索引删除。
(注:1、索引为非唯一索引,不在本次讨论之列。通过创建一个非唯一索引,让P或U约束使用,可避免在Enable或Disable P或U约束时重建索引,同时也避免drop constraint时,删除相关的索引。
2、当Disable constraint时使用keep index选项,同样可以保留相应索引。)
而10G中,即使索引为唯一索引,在Disable Constraint时,也不会删除相应的索引。
用sm$ts_used、sm$ts_free视图来查看表空间使用情况还是比较方便的。结构简单,只有两列,用来大致估估使用情况还是挺实用的。
SYS@TADBA> select u.tablespace_name, u.bytes, f.bytes 2 from sm$ts_used u, sm$ts_free f 3 where u.tablespace_name = f.tablespace_name; TABLESPACE_NAME BYTES BYTES -------------------- ----------------- ----------------- PERFSTAT 17061511168 18589679616 SYSTEM 182059008 80019456 UNDOTBS1 186261504 2112159744 USER01 10485760 1063190528 已选择4行。 |
在本机使用sqlplus调用dbms_metadata.get_ddl时,发现查询不到结果:
SYS@TADBA> select dbms_metadata.get_ddl('TABLE','DUAL','SYS') from dual; DBMS_METADATA.GET_DDL('TABLE','DUAL','SYS') ---------------------------------------------------------------------------- SYS@TADBA> |
10G开始,引入mutexes机制用以代替library cache pin
关于mutexes的一些解释:
转自http://space.itpub.net/?uid-756652-action-viewspace-itemid-348176
Mutexes are new thing in 10.2 and they enable shared access to objects in somewhat similar manner than shared latches, that every successful get of particular mutex will increment its value and release will decrement. When the count is zero, no-one has the mutex and it is safe to get it in exclusive mode too. However they are more fine grained than kgl latches and provide better waiting mechanism as far as I understand.
Enqueue等待事件中,TYPE为TX,MODE为6的等待,应该是最为常见,解决也相对较为容易的一种。
出现这种类型的等待,一般都是通过找出堵住其它会话的进程,通知应用提交或回滚事物,或是强制杀掉进程来解决。
下面是一个的生产案例:
找到一款不错WINDOWS下的命令行管理的工具包-PsTools,工具挺多的,简介其中两个小工具:
1、pslist:类似于UNIX下的ps命令
C:\Documents and Settings\NiceDream>pslist oracle pslist v1.28 - Sysinternals PsList Copyright ? 2000-2004 Mark Russinovich Sysinternals Process information for OONICEDREAM: Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time oracle 3820 8 10 165 135956 0:00:00.578 0:01:45.093 |
Thd为线程数,当前Oracle进程有10个线程。
用TOAD自带的工具SQLMonitor,把Log Switch Frequency Map这一功能的SQL抓了出来。
Log Switch Frequency Map 显示每一天中,各个小时LOG切换的次数。用于体现数据库负载压力,还是有一定作用的。
对于archive模式的数据库,这些数据也可以理解为归档的数量,或者把V$LOG_HISTORY换成V$ARCHIVED_LOG,效果相同。
站内搜索