查询dba_segmetns 异常慢,在11g 某个库里。
Encountering Slow Performance Reading *_SEGMENTS or *_TS_QUOTAS (文档 ID 1491748.1) 转到底部转到底部
In this Document
Symptoms
Changes
Cause
Solution
References
APPLIES TO:
Oracle Database - Standard Edition - Version 10.2.0.5 to 12.1.0.1 [Release 10.2 to 12.1]
Oracle Database - Personal Edition - Version 10.2.0.5 to 12.1.0.1 [Release 10.2 to 12.1]
Oracle Database - Enterprise Edition - Version 10.2.0.5 to 12.1.0.1 [Release 10.2 to 12.1]
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Information in this document applies to any platform.
View affected include: DBA_SEGMENTS, USER_SEGMENTS, DBA_TS_QUOTAS, USER_TS_QUOTAS
SYMPTOMS
Queries on DBA_SEGMENTS or USER_SEGMENTS involving the columns BYTES, BLOCKS, or EXTENTS are very slow.
Queries on DBA_TS_QUOTAS or USER_TS_QUOTES on columns BYTES or BLOCKS are also slow.
You have tablespaces using LOCAL extent management and MANUAL segment space management.
If you perform the following query, you will find that a large number of segments (probably in the 1000s or more) are listed as SLOW_SEGS:
select tablespace_name
, count(*) as seg_cnt
, sum(DECODE(bitand(segment_flags,131072),0,1)) as slow_segs
from sys.sys_dba_segs
where bitand(segment_flags,1)=1
and segment_type not in ('ROLLBACK', 'DEFERRED ROLLBACK', 'TYPE2 UNDO')
group by tablespace_name
having sum(DECODE(bitand(segment_flags,131072),0,1)) > 0;
TABLESPACE_NAME SEG_CNT SLOW_SEGS
------------------------------ ---------- ----------
SYSTEM 2968 2388
SYSAUX 2053 1444
DATA 10322 8021
USERS 755 510
CHANGES
This may be seen after upgrading to Oracle Database 11.2 and may get worse over time.
CAUSE
This is caused by the issue described in Document 12940620.8. There is a problem caching segment sizing information that is resulting in queries to these views having to compute sizing information for every segment on the fly in tablespaces with LOCAL extent management and MANUAL segment space management.
SOLUTION
Applying Patch 12940620 will prevent the problem from getting worse. After applying the patch, you can run the following PL/SQL block as sysdba which corrects sizing information on the segments:
begin
for t in (
select distinct tablespace_name
from sys.sys_dba_segs
where bitand(segment_flags,131073) = 1
and segment_type not in ('ROLLBACK', 'DEFERRED ROLLBACK', 'TYPE2 UNDO')
and tablespace_name != 'SYSTEM'
)
loop
dbms_space_admin.tablespace_fix_segment_extblks(t.tablespace_name);
end loop;
end;
/
WARNING: This procedure may take some time to complete and there is a potential of it disrupting other activities on the database while it is running. You may wish to run it out of peak hours or during a deployment window.
This procedure can also be run without applying the patch as a workaround, but the problem will return over time as database activity causes segments to grow.
###
表现为单独查询可以接受。
SELECT owner,SEGMENT_NAME,(BYTES) / 1024 / 1024
MB FROM DBA_SEGMENTS
一旦加入排序,就异常慢
SELECT owner,SEGMENT_NAME, SUM(BYTES) / 1024 / 1024
MB FROM DBA_SEGMENTS GROUP BY owner,SEGMENT_NAME
ORDER BY 3 DESC
--查看等待事件为
enq-tx-content ,执行时间(sysdate - sql exec start (from v$session))超过 10个小时。
参考文档https://www.cnblogs.com/feiyun8616/p/6138333.html 查看 锁的源头为
-> 30 7wurkmg0thn0d enq: TX - row lock contention -> 1596 d0wra06b4q1su gc current multi block request (1596是阻塞源头 )
->阻塞源头: session 1596 USER DBBAT 等待事件为 gc current multi block request ,执行开始时间为 2019/10/22 7:41:52 ,持续时间为为10小时还没有结束
-》执行语句为:
INSERT INTO CST_DEP_STTN ( ***)
CRMBAT 1596 16529 ACTIVE opcrm pcrmapp01 sqlplus@pcrmapp01 (TNS V1-V3) SQL*Plus 2019/10/22 7:41:52 0000000FF9230770 3922867 0000001018E8C2D0 85 2 2147483644 0000001017D740E0 DEDICATED 85 CRMBAT 31838 55775 USER 000000105486F1B0 2521499418 d0wra06b4q1su 0 2019/10/22 7:41:52 16777217 0000001035B9B790 380981399 5rfk8u8bban4r 0 2019/10/22 7:41:52 16777216 91686 1 3669949024 0 732610847 200533 18 381503 0 59 37823 NO NONE NONE NO DISABLED ENABLED ENABLED 0 UNKNOWN UNKNOWN 11616 158 gc current multi block request file# 21 0000000000000015 block# 52993 000000000000CF01 id# 33554440 0000000002000008 3871361733 11 Cluster 0 37793 WAITING 37793271808 -1 0 crmo DISABLED FALSE FALSE FIRST EXEC 100 0000001018E8C2D0 77
-》被堵赛进程;seesion 2118 DBA等待事件为 enq: TX - contention name ,对象为usn<<16 | slot 45878 (undo数据库块),执行开始时间为 2019/10/22 8:27:26. 持续时间为10小时还没有结束
->执行语句为:
SELECT *
FROM (SELECT owner,SEGMENT_NAME, SUM(BYTES) / 1024 / 1024 MB
FROM DBA_SEGMENTS
GROUP BY owner,SEGMENT_NAME
ORDER BY 3 DESC)
WHERE ROWNUM < 15
DBMGR 2118 22623 ACTIVE oracle11g yumserver sqlplus@yumserver (TNS V1-V3) SQL*Plus 2019/10/22 8:27:26 0000001011322BF8 3923185 0000001000EC4680 87 3 2147483644 0000001019413248 DEDICATED 0 SYS 25589 35954 USER 00000010356FCA48 2695323532 54017vkhafrwc 0 2019/10/22 8:27:26 16777280 00000010477BC398 3933222116 dyk4dprp70d74 1 2019/10/22 8:27:26 17368993 4964 16 4964 16 3669949024 0 732737580 -1 23 1053699 0 59 35089 NO NONE NONE NO DISABLED ENABLED ENABLED 0 VALID 1 1596 VALID 1 1596 904 778 enq: TX - contention name|mode 1415053316 0000000054580004 usn<<16 | slot 458783 000000000007001F sequence 200458 0000000000030F0A 1893977003 0 Other 0 35086 WAITING 35085915534 -1 0 SYS$USERS DISABLED FALSE FALSE FIRST EXEC 100 0000001000EC4680 121
查询dba_segments 有锁的原因,是因为一张表发生大量的数据变动,为了防止数据不一致,dba_segments 会从undo 获取数据,这样造成锁,
而undo 因为该表的dml 没有提交,所以导致查询也被锁住了。
建议找应用看看最近为何insert 这们慢。
另外Pl/SQL developer sessions 里集成了sql monitor 功能,也比较好用。
查询dba_segmetns 异常慢,在11g 某个库里。的更多相关文章
- [20170825]11G备库启用DRCP连接3.txt
[20170825]11G备库启用DRCP连接3.txt --//昨天测试了11G备库启用DRCP连接,要设置alter system set audit_trail=none scope=spfil ...
- [20170824]11G备库启用DRCP连接.txt
[20170824]11G备库启用DRCP连接.txt --//参考链接:http://blog.itpub.net/267265/viewspace-2099397/blogs.oracle.com ...
- mysql查询null异常:attempted to return null from a method with a primitive return type
select sum(deposit_amount)from tb_commission_ib_day mysql查询时报异常: attempted to return null from a met ...
- C++异常之七 标准库里的异常类
标准库里的异常类 C++标准提供了一组标准异常类,这些类以基类 Exception 开始,标准程序库抛出的所有异常,都派生于该基类,这些类构成如图所示的异常类的派生继承关系,该基类提供一个成员函数 w ...
- Oracle 11g 导库导不出空表问题
Oracle11g 会遇到这样的问题,用exp整库导出的时候,会遇到这样的问题,库里的空表没办法导出 select * from all_all_tables aa where aa.owner='U ...
- Gitlab源码库里代码提交后,如何触发jenkins自动构建?
版本库里代码提交后,如何触发jenkins自动构建?这是一个面试题,感觉自己回答的并不好,因为并没有用过这个功能,之前公司实际项目用的是svn版本管理,一般都用立刻构建,和定时任务构建(不管代码是否有 ...
- 微信昵称有特殊符号怎么保存到mysql库里?
微信昵称有特殊符号怎么保存到mysql库里? mysql库怎么保存emoji表情? 这里提供 1 种稳妥有效的方法: // 入库之前,使用 Base64 编码 String nickname = re ...
- sql语句查看库里有没有这张表,有就删除
查看库里有没有这张表,有就删除 DROP TABLE IF EXISTS 表名
- oracle 11g 建库 建表 增 删 改 查 约束
一.建库 1.(点击左上角带绿色+号的按钮) 2.(进入这个界面,passowrd为密码.填写完后点击下面一排的Test按钮进行测试,无异常就点击Connect) 二.建表 1-1. create t ...
随机推荐
- 网络空间安全基础篇(2)----wireshark
wireshrak是一款通过本地端口,来抓取通过以太网获取的文件包,包括SMB HTTP FTP TELNET 等包 在网络安全比赛中最常用的就是HTTP协议,TELNET协议,FTP协议,SMB协议 ...
- Python入门篇-数据结构堆排序Heap Sort
Python入门篇-数据结构堆排序Heap Sort 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.堆Heap 堆是一个完全二叉树 每个非叶子结点都要大于或者等于其左右孩子结点 ...
- go语言笔记2
上接Go语言学习笔记(一) 11 Go错误处理11.1 nil函数通常在最后的返回值中返回错误信息.使用errors.New 可返回一个错误信息: package main ...
- Docker万字详解!
一.简介 1.了解Docker的前生LXC LXC为Linux Container的简写.可以提供轻量级的虚拟化,以便隔离进程和资源,而且不需要提供指令解释机制以及全虚拟化的其他复杂性.相当于C+ ...
- 2019安徽省程序设计竞赛 D.自驾游(最短路)
这道题最后没过,估计是痛失省一了,现在来补一下,当时思路是对的应该是代码出了问题导致样例没过最后nc的除了2,一直WA 题意: 给一张联通图,有两个导航系统,其中一个系统认为第i条边的权值是Pi,另一 ...
- HTTP Status 500 - DateConverter does not support default String to 'Date' conversion.错误
//自己指定一个类型转换器(将String转成Date) DateConverter converter = new DateConverter(); converter.setPattern(new ...
- Oracle中INSTR函数与SQL Server中CHARINDEX函数
Oracle中INSTR函数与SQL Server中CHARINDEX函数 1.ORACLE中的INSTR INSTR函数格式:INSTR(源字符串, 目标字符串, 起始位置, 匹配序号) 说明:返回 ...
- 关于AndroidStudio的apk打包遇到的问题记录
12月份末尾,想来个总结,主要是得记一些重要的. 首先就得是AndroidStudi内的apk打包,就是弄当前项目app的安装包出来. 下面就说下具体步骤和注意问题. 首先 : 看到AndroidSt ...
- Win如何查看某个端口被谁占用并停掉
第一步在我们的电脑上按win+R键打开运行,输入cmd, 第二步进去命令提示符之后,输入“netstat -ano”,按回车键,查出所有端口,如下图所示: 第三步如果我们想找8089端口,输入nets ...
- 基于Centos7+Flask+Nginx+uWSGI+Python3的服务器网页搭建教程
之前完成了贴吧签到系统的搭建,笔者想将这个功能分享给更多人使用,所以尝试搭建了一个网页,一路遇到了很多问题,最终解决了,记录下过程分享给大家 首先安装 uWSGI ,和 Nginx 配套使用,具体用途 ...