Temp表空间上进程的查询

select a.tablespace, b.sid, b.serial#, a.blocks,c.sql_text
from v$sort_usage a,v$session b,v$sqltext c
where a.session_addr = b.saddr
and b.sql_address = c.address
order by a.tablespace,b.sid,b.serial#,c.address, c.piece;

查看表锁

select * from sys.v_$sqlarea where disk_reads>;

监控事例的等待

select event,sum(decode(wait_Time,0,0,1)) "Prev",
sum(decode(wait_Time,0,1,0)) "Curr",count(*) "Tot"
from v$session_Wait
group by event order by 4 ;

回滚段的争用情况

select name, waits, gets, waits/gets "Ratio"
from v$rollstat a, v$rollname b
where a.usn = b.usn;

查看前台正在发出的SQL语句

select user_name,sql_text
   from v$open_cursor
   where sid in (select sid from (select sid,serial#,username,program
   from v$session
   where status='ACTIVE'));

数据表占用空间大小情况

select segment_name,tablespace_name,bytes,blocks
from user_segments
where segment_type='TABLE'
ORDER BY bytes DESC ,blocks DESC;

查看表空间碎片大小

select tablespace_name,round(sqrt(max(blocks)/sum(blocks))*
(100/sqrt(sqrt(count(blocks)))),2) FSFI
from dba_free_space
group by tablespace_name order by 1;

查看表空间占用磁盘情况

select
b.file_id 文件ID号,
b.tablespace_name 表空间名,
b.bytes 字节数,
(b.bytes-sum(nvl(a.bytes,0))) 已使用,
sum(nvl(a.bytes,0)) 剩余空间,
sum(nvl(a.bytes,0))/(b.bytes)*100 剩余百分比
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_id,b.bytes
order by b.file_id;

查看Oracle 表空间使用率

SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
SPACE - NVL (FREE_SPACE, 0) || 'M' "USED_SPACE(M)",
ROUND ( (1 - NVL (FREE_SPACE, 0) / SPACE) * 100, 2) || '%'
"USED_RATE(%)",
FREE_SPACE || 'M' "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 --如果有临时表空间
SELECT D.TABLESPACE_NAME,
SPACE || 'M' "SUM_SPACE(M)",
USED_SPACE || 'M' "USED_SPACE(M)",
ROUND (NVL (USED_SPACE, 0) / SPACE * 100, 2) || '%' "USED_RATE(%)",
NVL (FREE_SPACE, 0) || 'M' "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(+)
ORDER BY 1;

 查看Temp 表空间实际使用磁盘大小

Select f.tablespace_name,
d.file_name "Tempfile name",
round((f.bytes_free + f.bytes_used) / 1024 / 1024, 2) "total MB",
round(((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / 1024 / 1024,
2) "Free MB",
round(nvl(p.bytes_used, 0) / 1024 / 1024, 2) "Used MB",
round((round(nvl(p.bytes_used, 0) / 1024 / 1024, 2) /
round((f.bytes_free + f.bytes_used) / 1024 / 1024, 2)) * 100,
2) as "Used_Rate(%)"
from SYS.V_$TEMP_SPACE_HEADER f,
DBA_TEMP_FILES d,
SYS.V_$TEMP_EXTENT_POOL p
where f.tablespace_name(+) = d.tablespace_name
and f.file_id(+) = d.file_id
and p.file_id(+) = d.file_id;

 查看session使用回滚段

SELECT  r.name 回滚段名,
s.sid,
s.serial#,
s.username 用户名,
t.status,
t.cr_get,
t.phy_io,
t.used_ublk,
t.noundo,
substr(s.program, 1, 78) 操作程序
FROM sys.v_$session s,sys.v_$transaction t,sys.v_$rollname r
WHERE t.addr = s.taddr and t.xidusn = r.usn
ORDER BY t.cr_get,t.phy_io;

 查看SGA区剩余可用内存

select name,
      sgasize/1024/1024        "Allocated(M)",
      bytes/1024            "**空间(K)",
      round(bytes/sgasize*100, 2)   "**空间百分比(%)"
   from (select sum(bytes) sgasize from sys.v_$sgastat) s, sys.v_$sgastat f
   where f.name = 'free memory';

 监控表空间I/O比例

select df.tablespace_name name,df.file_name “file”,f.phyrds pyr,
f.phyblkrd pbr,f.phywrts pyw, f.phyblkwrt pbw
from v$filestat f, dba_data_files df
where f.file# = df.file_id
order by df.tablespace_name;

 监控SGA命中率

select a.value + b.value "logical_reads",
c.value "phys_reads",
round(100 * ((a.value+b.value)-c.value) / (a.value+b.value)) "BUFFER HIT RATIO"
from v$sysstat a, v$sysstat b, v$sysstat c
where a.statistic# = 38 and
b.statistic# = 39 and
c.statistic# = 40 ;

监控 SGA 中字典缓冲区的命中率

select parameter, gets,Getmisses , getmisses/(gets+getmisses)*100 "miss ratio",
(1-(sum(getmisses)/ (sum(gets)+sum(getmisses))))*100 "Hit ratio"
from v$rowcache
where gets+getmisses <>0
group by parameter, gets, getmisses ;

监控 SGA **享缓存区的命中率,应该小于1%

select sum(pins) "Total Pins", sum(reloads) "Total Reloads",
sum(reloads)/sum(pins) *100 libcache
from v$librarycache;

监控 SGA 中重做日志缓存区的命中率,应该小于1%

SELECT name, gets, misses, immediate_gets, immediate_misses,
Decode(gets,0,0,misses/gets*100) ratio1,
Decode(immediate_gets+immediate_misses,0,0,
immediate_misses/(immediate_gets+immediate_misses)*100) ratio2
FROM v$latch WHERE name IN ('redo allocation', 'redo copy');

 监控内存和硬盘的排序比率,最好使它小于 .10

SELECT name, value
FROM v$sysstat
WHERE name IN ('sorts (memory)', 'sorts (disk)') ;

监控字典缓冲区

SELECT SUM(GETS) "DICTIONARY GETS",SUM(GETMISSES) "DICTIONARY CACHE GET MISSES"
FROM V$ROWCACHE ;

 系统用户建在system表空间中的表">非系统用户建在SYSTEM表空间中的表

SELECT owner,table_name
FROM DBA_TABLES
WHERE tablespace_name in('SYSTEM','USER_DATA') AND
owner NOT IN('SYSTEM','SYS','OUTLN', 'ORDSYS','MDSYS','SCOTT', 'HOSTEAC');

性能最差的SQL

SELECT * FROM ( SELECT PARSING_USER_ID EXECUTIONS,SORTS,COMMAND_TYPE,DISK_READS,sql_text
FROM v$sqlarea
ORDER BY disk_reads DESC)
WHERE ROWNUM<100;

读磁盘数超100次的sql

select * from sys.v_$sqlarea where disk_reads>100;

最频繁执行的sql

select * from sys.v_$sqlarea where executions>100;

 查询使用CPU多的用户session

select a.sid,spid,status,substr(a.program,1,40) prog,a.terminal,osuser,value/60/100 value
from v$session a,v$process b,v$sesstat c
where c.statistic#=12 and
c.sid=a.sid and
a.paddr=b.addr
order by value desc;

当前每个会话使用的对象数

SELECT a.sid,s.terminal,s.program,count(a.sid)
FROM V$ACCESS a,V$SESSION s
WHERE a.owner <> 'SYS'AND s.sid = a.sid
GROUP BY a.sid,s.terminal,s.program
ORDER BY count(a.sid) ;

查询数据库当前进程的连接数

select count(*) from v$process

查看数据库当前会话的连接数

select count(*) from v$session

 查看数据库的并发连接数

select count(*) from v$session where status='ACTIVE'

 查看当前数据库建立的会话情况

select sid,serial#,username,program,machine,status from v$session

 查询数据库允许的最大连接数 或者 show parameter processes

select value from v$parameter where name ='processes'

修改数据库允许的最大连接数 alter system set processes = 300 scope = spfile

查看当前有哪些用户正在使用数据

select osuser,a.username,cpu_time/executions/1000000||'s',sql_fulltext,machine from v$session a,v$sqlarea b where a.sql_address = b.address order by cpu_time/executions desc

ORACLE常用性能监控SQL的更多相关文章

  1. ORACLE常用性能监控SQL【一】

    目录(?)[+] 系列 ORACLE常用性能监控SQL[一] ORACLE常用性能监控SQL[二] Oracle-动态性能视图解读 系列 死锁后的解决办法 生成Kill Session语句 查看导致死 ...

  2. ORACLE常用性能监控SQL(二)

    查询Oracle正在执行的sql语句及执行该语句的用户 SELECT b.sid oracleID, b.username 登录Oracle用户名, b.serial#, spid 操作系统ID, p ...

  3. Oracle 常用性能监控SQL语句

    1.  --查看表锁     SELECT * FROM SYS.V_$SQLAREA WHERE DISK_READS > 100; 2.  --监控事例的等待     SELECT EVEN ...

  4. Oracle种常用性能监控SQL语句

    --Oracle常用性能监控SQL语句 --1 SELECT * FROM SYS.V_$SQLAREA WHERE DISK_READS > 100; --2 监控事例的等待 SELECT E ...

  5. Oracle常用性能监控语句解析

    转:http://www.cnblogs.com/preftest/archive/2010/11/14/1876856.html 1.监控等待事件select event,sum(decode(wa ...

  6. oracle AWR性能监控报告生成方法

    目前相当一部分公司会用到oracle,在做性能测试的时候,对数据库的监控很重要,那么这里先介绍下如何生成oracle自带的awr监控报告,而具体报告的内容分析会放在后续的博客中 oracle性能分析入 ...

  7. Oracle常用系统查询SQL

    以user1身份登录oracle,然后执行:select table_name from user_tables;或select table_name from tabs; 常用SQL --1.查询o ...

  8. Linux服务器常用性能监控命令汇总

    1.ifconfig 网卡数目.ip地址.Mac地址.MTU大小 eth0 Link encap:Ethernet HWaddr 00:0d:3a:50:12:e9 inet addr:10.0.0. ...

  9. Oracle常用几种Sql用法

    前几天客户提出一个月报,经过了解需求及公式等过程长达20小时,总算基本模型出来了,贴出来啥晒,对于我这种菜鸟来说也算小有提高,虽然Sql语句不是很庞大,但是里面涉及到了几种算法,个人觉得还是经常能用到 ...

随机推荐

  1. SpringBoot日记——Spring的安全配置-登录认证与授权

    安全是每个项目开发中都需要考虑的,比如权限控制,安全认证,防止漏洞攻击等. 比较常见的安全框架有:Apache的shiro.Spring Security等等,相信用shiro的用户群体更多,而sec ...

  2. jackjson-databind-2.9.3 笔记

    问题 客户端请求: {"skip":0,"take":10,"corpName":"","cityCode&q ...

  3. CentOS6.9下升级默认的OpenSSH操作记录(升级到OpenSSH_7.6p1)

    近期对IDC机房服务器做了一次安全漏洞扫描,漏扫结果显示服务器的OpenSSH版本太低(CentOS6默认是OpenSSH_5.3p1),存在漏洞隐患,安全部门建议升级到OpenSSH_7.6p1.升 ...

  4. Linux下路由配置梳理

    在日常运维作业中,经常会碰到路由表的操作.下面就linux运维中的路由操作做一梳理:---------------------------------------------------------- ...

  5. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-A-Single Wildcard Pattern Matching

    #include<iostream> #include<algorithm> #include<stdio.h> #include<string.h> ...

  6. C. A Mist of Florescence

    链接 [http://codeforces.com/contest/989/problem/C] 题意 给定A B C D四个字符个数,让你构造一个矩阵使得他们的个数恰好那么多,联通块算一块 分析 构 ...

  7. easyUI中textbox或number的数值大小校验

    例:textbox里面,要求做两个textbox名字为(A,B),其中两个的数字大小范围是-10~10之间,之后其中A的值必须大于B所填的数字,如果输入错误,则提示出弹出框,并清空数据. <!D ...

  8. Daily scrum 12.21

    今天ui组反映了一个数据库数据类型的问题,开发人员在完成任务后再去处理. Member Today’s task 林豪森 与学霸其他小组交流,处理整合问题 宋天舒 修复数据库问题 张迎春 修复数据库问 ...

  9. package.json中的几种依赖注册对象解析

    本博文根据官网+google翻译+自己的理解,欢迎指出翻译的不到位的地方. package.json的重要性不言而喻,一直以来对几种依赖注册对象的区别和作用不是很了解,今日一探究竟. dependen ...

  10. Python小笔记

    最近在学习Python  以前也学过一些编程语言 但是都不扎实  由于工作的原因 需要学习Python做一些处理 刚开始学习总有多多少少的不适应  从今天开始打算将我在学习中遇到的困难以及疑问记录下来 ...