10g对等待事件进行了分类
为我们根据等待事件判断系统的问题尽可能的指明方向...[@more@]SQL> select distinct wait_class#,wait_class from v$event_name order by wait_class#;WAIT_CLASS# WAIT_CLASS----------- ---------------------------------------------------------------- 0 Other 1 Application 2 Configuration 3 Administrative 4 Concurrency 5 Commit 6 Idle 7 Network 8 User I/O 9 System I/O 10 SchedulerWAIT_CLASS# WAIT_CLASS-----
v$metric和v$metric_history的区别
10g的doc居然没有查到这2个视图的解释...这2个视图的结构完全相同,数据到底有什么区别?[@more@]一下是11gR2中这个视图的解释:V$METRIC displays the most recent statistic values for the complete set of metrics captured by the AWR infrastructure.V$METRIC_HISTORY displays all the available statistic values for the complete set of metrics captured by the AWR infrastructure.这里提到V$METRIC 显示了recent的数据,而V$METRIC_HISTORY显示了all,查询一下发现recent=1分钟,all表示至实例启动以来:SQL> select min(b
一个有用的函数-实现dump函数的convert!
利用此函数可以实现dump函数的反转[@more@]链接:http://structureddata.org/2007/10/16/how-to-display-high_valuelow_value-columns-from-user_tab_col_statistics/create or replace function display_raw (rawval raw, type varchar2) return varchar2 is cn number;cv varchar2(32); cd date; cnv nvarchar2(32);cr rowid; cc char(32); begin if (type = 'NUMBER') then dbms_stats.convert_raw_value(rawval, cn); return to_char(cn); elsif (type = 'VARCHAR2') then dbms_stats.conver
监视index的使用看看是否需要重建!
我们知道index的key值被删除之后其使用的空间并不会理解释放,只有当这个index block空间完全不被使用之后才可以被再次使用,这也就是index的pctused为0的缘故。有些时候由于表中的数据被大量删除,此时index的leaf block中保留了很多没有用的key 值,不仅浪费了空间,而且再次使用该index时效率可能也极其低下,可以通过对index的监视以及对index结构的有效性验证来判断index是否需要重建,重建时在高可用性系统中当然还需要考虑lock的问题。[@more@]SQL> desc t 名称 是否为空? 类型 ---------
2篇对session产生sql跟踪信息的不错的文章!
http://www.eygle.com/case/Use.sql_trace.to.Diagnose.database.htmhttp://xiaoxiongg.itpub.net/post/6060/31115[@more@]http://www.eygle.com/case/Use.sql_trace.to.Diagnose.database.htmhttp://xiaoxiongg.itpub.net/post/6060/31115
利用trcsess合并以共享模式连接的session所产生的tracefile!
我们知道mts下存在多个process为一个session服务的情况,这样如果想开启该session的trace功能,那么产生的trace文件势必就有多个文件,如何把这个多个文件中的session信息提取出来就显的尤为重要,oracle提供的trcsess工具可以帮助我们,通过trcsess处理之后的tracefile就可以通过tkprof继续处理了。[@more@]SQL> select distinct sid from v$mystat;SID----------138SQL> select saddr,paddr,server,sid,serial# from v$session where sid=138;SADDR PADDR SERVER SID SERIAL#-------- -------- --------- ---------- ----------69
获得tracefile name的脚步!
可以利用下面的脚本获得tracefile name,在11g可以非常方便的获得,其他版本相对比较麻烦。在oradebug中也很容易获得。[@more@]select pa.value ||decode(d.PLATFORM_NAME,'Microsoft Windows IA (32-bit)','','Microsoft Windows IA (64-bit)','','/') || i.instance_name || '_ora_' || pr.spid || '.trc' as trace_filefrom v$session s, v$process pr, v$parameter pa, v$instance i , v$database dwhere s.username = user and s.paddr = pr.addrand pa.name='user_dump_dest';
如何看懂执行计划!
The execution order in EXPLAIN PLAN output begins with the line that is the furthest indented to the right. The next step is the parent of that line. If two lines are indented equally, then the top line is normally executed first. 在doc上看到了,记录一下[@more@]SQL> select count(*) from dba_objects;COUNT(*)----------11345Execution Plan----------------------------------------------------------Plan hash value: 2598313856---------------------------------------------------------------------------
会引起排序的sql语句类型!
闲的无聊,看看9i 的性能优化ocp考试题,题中提到了的一点内容,记得在doc上也看到过,不过从10g开始,group by不一定会排序。[@more@]The types of SQL statements that can cause database sorts to occur include the following: ORDER BY,GROUP BY, SELECT DISTINCT, UNION, INTERSECT, MINUS, ANALYZE, CREATE INDEX, joinsbetween tables on columns that are not indexed.
基于函数index的一点简单测试!
基于函数index的一点简单测试![@more@]SQL> create table tt as select *from t;表已创建。SQL> select *from tt; ID NAME---------- ---------- 1 abc 2 bcd 3 cde 123 test 321 testabcSQL> insert into tt values(null,null);已创建 1 行。SQL> insert into tt values(null,null);已创建 1 行。SQL> commit;提交完成。SQL> create index idx_tt_id on tt(id desc);索引已创建。--================================Ascending unique indexes allow multiple NULL values
memory advisor!
10g em中给出了memory advisor,其中如果设置了sga_target的值的话,那么该顾问通过图表的形式给出的是sga的建议值,该建议值是如何被计算的呢,其实是通过下面公式:select sga_size,100* round(((estd_db_time1 - estd_db_time)/estd_db_time1),2)from (select sga_size,estd_db_time ,(select estd_db_time from v$sga_target_advice where sga_size_factor=1) estd_db_time1 from v$sga_target_advice where sga_size_factor<>1order by sga_size)通过上面查询可以获得sga_size以及db_time的改善百分比,在excel中以sga_size为横
SQL Access Advisor!
doc的原话,随手记录!The SQL Access Advisor's recommendations are significantly improved if you gather structural statistics about table and index cardinalities, and the distinct cardinalities of every dimension level column, JOIN KEY column, and fact table key column. You do this by gathering either exact or estimated statistics with the DBMS_STATS package. Because gathering statistics is time-consuming and extreme statistical accuracy is not required, it is generally preferable to estimate sta
Using the Undo Advisor!
doc原话,随手记录一下!http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/storage003.htm#sthref369[@more@]Using the Undo AdvisorThe amount of undo data that can be retained depends on the size of your undo tablespace. If your tablespace is set to auto-extend, then Oracle automatically acquires space as needed. If you choose to disable auto-extend, however, then you are responsible for ensuring that the undo tablespace has enough space. In this situation, Oracle configures the undo re
Sql Tuning Advisor的大致过程测试!
可以通过em使用Sql Tuning Advisor来寻找sql的优化建议,这里使用了package:DBMS_SQLTUNE获得sql优化的建议,只是想大致了解下Sql Tuning Advisor的过程。[@more@]SQL> create table t1(id int , name varchar2(10));表已创建。SQL> create table t2(id int , name char(1000));表已创建。SQL> begin 2 for i in 1..10000 loop 3 insert into t1 values(i,'a'||i); 4 insert into t2 values(i,'b'||i); 5 end loop 6 ; 7 commit; 8 end; 9 /PL/SQL 过程已成功完成。SQL> DECLARE 2 my_task_name VARCHAR2
Segment Advisor的一点简单测试!
尽管可以通过em使用Segment Advisor,不过我还是想通过调用dbms_advisor来简单的了解一下Segment Advisor的大致流程![@more@]SQL> create table tt1 as select * from dba_objects;表已创建。SQL> SET SERVEROUTPUT ONdeclareuf_blocks number ;uf_bytes number;fs1_blocks number;fs1_bytes number;fs2_blocks number;fs2_bytes number;fs3_blocks number;fs3_bytes number;fs4_blocks number;fs4_bytes number;full_blocks number;full_bytes number;begindbms_space.space_usage('TEST','TT1','TABLE',uf_blocks ,uf_bytes ,fs1
不同的连接方式性能对比!
表与表之间错误的连接方式会对性能产生巨大影响。[@more@]SQL> create table t(id int , name char(10));表已创建。SQL> create table tt(id int , name char(2000));表已创建。SQL> begin 2 for i in 1..10000 loop 3 insert into t values(i,'test'); 4 end loop; 5 commit; 6 end; 7 /PL/SQL 过程已成功完成。SQL> begin 2 for i in 1..10000 loop 3 insert into tt values(i,'test1'); 4 end loop; 5 commit; 6 end; 7 /PL/SQL 过程已成功完成。SQL> exec dbms_stats.gather_table_stats('TES
Dynamic Sampling!
The purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing plans.[@more@]Dynamic SamplingThe purpose of dynamic sampling is to improve server performance by determining more accurate selectivity and cardinality estimates. More accurate selectivity and cardinality estimates allow the optimizer to produce better performing pl
what is Goals for Tuning?
The objective of tuning a system is either to reduce the response time for end users of the system, or to reduce the resources used to process the same work.[@more@]The objective of tuning a system is either to reduce the response time for end users of the system, or to reduce the resources used to process the same work. You can accomplish both of these objectives in several ways:Reduce the Workload Balance the Workload Parallelize the Workload Reduce the WorkloadThis is what commonly constitute
query rewrite和基于函数的索引有关系?
The NOREWRITE hint disables the use of function-based indexes.看到这句话之后不太理解为什么提示NOREWRITE 的使用会丧失基于函数index的使用能力![@more@]出处:http://download.oracle.com/docs/cd/B10501_01/server.920/a96533/hintsref.htmThe NOREWRITE hint disables the use of function-based indexes.看到这句话之后不太理解为什么提示NOREWRITE 的使用会丧失基于函数index的使用能力!
按照oracle性能改进方法论的步骤来优化系统!
doc上的原话,记录一下,感觉写的很精彩![@more@]Steps in The Oracle Performance Improvement MethodGet candid feedback from users. Determine the performance project's scope and subsequent performance goals, as well as performance goals for the future. This process is key in future capacity planning. Get a full set of operating system, database, and application statistics from the system when the performance is both good and bad. If these are not available, then get whatever is available. Missing s