sf_Oracle

// 物理读分析

SELECT b.sql_id,a.hash_value, a.buffer_gets/1024 buffer_gets_kb, a.disk_reads/1024 disk_reads_kb,

 a.PHYSICAL_READ_BYTES/1024 physical_read_kb,a.PHYSICAL_WRITE_BYTES/1024 physical_write_kb,

 a.executions, a.parse_calls

FROM V$SQLAREA a,v$sql b,(

SELECT '9rpgcrjzqrjaa' SQL_ID FROM DUAL UNION

SELECT '6t49g7kh115ja' SQL_ID FROM DUAL UNION) c

WHERE a.hash_Value = b.hash_Value AND b.sql_id = c.sql_id

order by disk_reads_kb desc

 

// 执行计划分析

select '202ss5rgtt2cx' sql_id,plan_table_output 

from table(dbms_xplan.display_cursor('202ss5rgtt2cx')) 

union

select 'awhv64yra0sct' sql_id,plan_table_output 

from table(dbms_xplan.display_cursor('awhv64yra0sct')) 

 

// 执行参数分析

select b.*

  from dba_hist_snapshot a, dba_hist_sqlbind b

 where a.snap_id = b.snap_id

   and a.end_interval_time between

       to_date('20140730 00:00:00', 'yyyymmdd HH24:MI:SS') and

       to_date('20140731 23:59:00', 'yyyymmdd HH24:MI:SS')

   and b.sql_id = 'dfunt68kpxwj5';

 

 

select b.snap_id,

       b.dbid,

       b.sql_id,

       b.name,

       b.position,

       b.datatype_string,

       b.value_string

  from dba_hist_snapshot a, dba_hist_sqlbind b

 where a.snap_id = b.snap_id

   and a.end_interval_time between

       to_date('20140730 00:00:00', 'yyyymmdd HH24:MI:SS') and

       to_date('20140731 23:59:00', 'yyyymmdd HH24:MI:SS')

   and b.sql_id = 'dfunt68kpxwj5'

order by b.snap_id,b.position;

 

 

// 查询每个表的列值的分布情况,合理规划索引

select table_name, column_name, num_distinct

  from dba_tab_columns

 where table_name in ('TT_DTS_RECORD',

                      'LSCM_TA_TMALL_SHIPPED_ORDER')

 order by table_name,num_distinct desc;

你可能感兴趣的:(oracle)