一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

oracle sql性能查證

 穿越洪荒客 2017-01-18

--1、耗時(shí)長sql查證:--

select * from (select SQL_TEXT,round(ELAPSED_TIME/1000000,2),round(ELAPSED_TIME/1000000/EXECUTIONS,2) perELAPSED_time,EXECUTIONS
  from (select * from v$sql order by ELAPSED_TIME desc) where rownum<26) order by perELAPSED_time desc;

--2、占用cpu時(shí)間長的sql查證:--

select * from (select SQL_TEXT,round(CPU_TIME/1000000,2),round(CPU_TIME/1000000/EXECUTIONS,2) percpu_time,EXECUTIONS
  from (select * from v$sql order by CPU_TIME desc) where rownum<26) order by percpu_time desc;


--3、磁盤讀數(shù)據(jù)量大sql查證:--

select sql_text,disk_reads,EXECUTIONS from (select * from v$sqlarea order by disk_reads desc) where rownum<26;

 

--4、獲取超時(shí)sql--
select username,sid,opname, round(sofar*100 / totalwork,0) progress, time_remaining,sql_text
 from v$session_longops , v$sql where sql_address = address and sql_hash_value = hash_value
  order by start_time;

--5、查看表空間大小和使用情況all--

SELECT D.TABLESPACE_NAME,SPACE 'SUM_SPACE(M)',BLOCKS SUM_BLOCKS,SPACE-NVL(FREE_SPACE,0) 'USED_SPACE(M)',
ROUND((1-NVL(FREE_SPACE,0)/SPACE)*100,2) 'USED_RATE(%)',FREE_SPACE 'FREE_SPACE(M)'
FROM 
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) SPACE,SUM(BLOCKS) BLOCKS
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) D,
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F
WHERE  D.TABLESPACE_NAME = F.TABLESPACE_NAME(+)
UNION ALL  --if have tempfile 
SELECT D.TABLESPACE_NAME,SPACE 'SUM_SPACE(M)',BLOCKS SUM_BLOCKS, 
USED_SPACE 'USED_SPACE(M)',ROUND(NVL(USED_SPACE,0)/SPACE*100,2) 'USED_RATE(%)',
NVL(FREE_SPACE,0) 'FREE_SPACE(M)'
FROM 
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES)/(1024*1024),2) SPACE,SUM(BLOCKS) BLOCKS
FROM DBA_TEMP_FILES
GROUP BY TABLESPACE_NAME) D,
(SELECT TABLESPACE_NAME,ROUND(SUM(BYTES_USED)/(1024*1024),2) USED_SPACE,
ROUND(SUM(BYTES_FREE)/(1024*1024),2) FREE_SPACE
FROM V$TEMP_SPACE_HEADER
GROUP BY TABLESPACE_NAME) F
WHERE  D.TABLESPACE_NAME = F.TABLESPACE_NAME(+);

 

--6、查證外鍵沒有建索引的情況--

ps$tkyte@ORA10G> column columns format a30 word_wrapped
ops$tkyte@ORA10G> column tablename format a15 word_wrapped
ops$tkyte@ORA10G> column constraint_name format a15 word_wrapped

select table_name, constraint_name,
cname1 || nvl2(cname2,','||cname2,null) ||
nvl2(cname3,','||cname3,null) || nvl2(cname4,','||cname4,null) ||
nvl2(cname5,','||cname5,null) || nvl2(cname6,','||cname6,null) ||
nvl2(cname7,','||cname7,null) || nvl2(cname8,','||cname8,null)
columns
from ( select b.table_name,
b.constraint_name,
max(decode( position, 1, column_name, null )) cname1,
 max(decode( position, 2, column_name, null )) cname2,
 max(decode( position, 3, column_name, null )) cname3,
 max(decode( position, 4, column_name, null )) cname4,
 max(decode( position, 5, column_name, null )) cname5,
 max(decode( position, 6, column_name, null )) cname6,
 max(decode( position, 7, column_name, null )) cname7,
 max(decode( position, 8, column_name, null )) cname8,
 count(*) col_cnt
 from (select substr(table_name,1,30) table_name,
 substr(constraint_name,1,30) constraint_name,
 substr(column_name,1,30) column_name,
 position
 from user_cons_columns ) a,
 user_constraints b
 where a.constraint_name = b.constraint_name
 and b.constraint_type = 'R'
 group by b.table_name, b.constraint_name
 ) cons
 where col_cnt > ALL
 ( select count(*)
 from user_ind_columns i
 where i.table_name = cons.table_name
 and i.column_name in (cname1, cname2, cname3, cname4,
 cname5, cname6, cname7, cname8 )
 and i.column_position <= cons.col_cnt
 group by i.index_name
 ) order by table_name;

--7、檢查被鎖的對象--

select l.OBJECT_ID,l.SESSION_ID,l.oracle_username,l.LOCKED_MODE,o.object_name
from v$locked_object l,dba_objects o
where l.OBJECT_ID=o.OBJECT_ID;

--8、查看臨時(shí)表空間情況--

SELECT  d.status 'Status', d.tablespace_name 'Name', d.contents 'Type', d.extent_management 'Extent Management',
                TO_CHAR(NVL(a.bytes / 1024 / 1024, 0),'99,999,990.900') 'Size (M)',
                NVL(t.bytes, 0)/1024/1024 ||'/'||NVL(a.bytes/1024/1024, 0) 'Used (M)',
                TO_CHAR(NVL(t.bytes / a.bytes * 100, 0), '990.00') 'Used %'
          FROM  sys.dba_tablespaces d,
                (select tablespace_name, sum(bytes) bytes from dba_temp_files group by tablespace_name) a,
                (select tablespace_name, sum(bytes_cached) bytes from v$temp_extent_pool group by tablespace_name) t
         WHERE  d.tablespace_name = a.tablespace_name(+)
           AND  d.tablespace_name = t.tablespace_name(+)
           AND  d.extent_management like 'LOCAL'
           AND  d.contents like 'TEMPORARY';

--9. 查看并解除死鎖 --         
select l.OBJECT_ID,l.SESSION_ID,l.oracle_username,l.LOCKED_MODE,o.object_name,t.serial#
from v$locked_object l,dba_objects o,v$session t
where l.OBJECT_ID=o.OBJECT_ID and l.session_id=t.sid;

alter system kill session 'SESSION_ID,t.serial#';

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    日韩特级黄片免费观看| 九九热国产这里只有精品 | 国产一区二区三区丝袜不卡| 一级片二级片欧美日韩| 又黄又硬又爽又色的视频| 日韩综合国产欧美一区| 国产色第一区不卡高清| 91亚洲人人在字幕国产| 日韩精品视频香蕉视频| 亚洲午夜精品视频观看| 日本加勒比在线播放一区| 91久久国产福利自产拍 | 内射精子视频欧美一区二区| av中文字幕一区二区三区在线| 九九视频通过这里有精品| 一区二区三区日本高清| 夜夜嗨激情五月天精品| 日韩欧美国产三级在线观看| 日本高清中文精品在线不卡| 久久中文字幕中文字幕中文| 果冻传媒在线观看免费高清| 色好吊视频这里只有精| 视频在线观看色一区二区| 亚洲国产成人久久99精品| 亚洲国产一区精品一区二区三区色| 日韩国产精品激情一区| 国产成人精品一区二三区在线观看 | 免费午夜福利不卡片在线 视频 | 久久热这里只有精品视频| 少妇人妻精品一区二区三区| 东京热加勒比一区二区三区| 91精品蜜臀一区二区三区| 亚洲综合色婷婷七月丁香| 热情的邻居在线中文字幕| 国产亚洲欧美日韩国亚语| 国产精品久久三级精品| 欧美中文日韩一区久久| 熟女一区二区三区国产| 国产午夜精品亚洲精品国产| 东北女人的逼操的舒服吗| 偷拍偷窥女厕一区二区视频|