Oralce 检查表和索引的并行度 DOP 脚本

简介: 数据库的并行度使用需要很谨慎,很容易造成数据库运行缓慢以及严重的等待。

数据库的并行度使用需要很谨慎,很容易造成数据库运行缓慢以及严重的等待。


比较常见的由于 并行度 设置错误导致的等待事件:


  • PX Deq Credit: send blkd


  • PX Deq Credit: need buffer


错误的并行度设置往往可能是由于在创建索引或者重建索引时开启并行度创建,后来忘记关闭导致!


createindex<indexname>on<table>(<columns>)parallel4;
alterindex<indexname>rebuildparallel4;


✅ 使用并行度设置后的正确操作:


alterindex<indexname>noparallel;


当我们遇到这样的等待事件很严重时,可以使用下方脚本快速查看是否存在不正确的并行度设置!


📢 注意: 以下脚本已经过内部测试,但是,不保证它对您有用。确保在使用前在测试环境中运行它。


该 SQL 查询当前数据库主机 CPU 数以及每个 CPU 默认的并行度:


colnameformata30colvalueformata20RemHowmanyCPUdoesthesystemhave?RemDefaultdegreeofparallelismisRemDefault=parallel_threads_per_cpu*cpu_countRem-------------------------------------------------;
selectsubstr(name,1,30) Name , substr(value,1,5) Valuefromv$parameterwherenamein ('parallel_threads_per_cpu' , 'cpu_count' );


1.png


2.png


该 SQL 检查当前数据库中所有用户中存在不同并行度的 表:


setpagesize1000colownerformata30coldegreeformata10colinstancesformata10RemNormallyDOP :=degree*InstancesRemSeethefollowingNotefortheexactformula.
RemNote:260845.1OldandnewSyntaxforsettingDegreeofParallelismRemHowmanytablesauserhavewithdifferentDOPsRem-------------------------------------------------------;
select*from (
selectsubstr(owner,1,15) Owner , ltrim(degree) Degree,
ltrim(instances) Instances,
count(*) "Num Tables" , 'Parallel'fromall_tableswhere ( trim(degree) !='1'andtrim(degree) !='0' ) or( trim(instances) !='1'andtrim(instances) !='0' )
groupbyowner, degree , instancesunionselectsubstr(owner,1,15) owner , '1' , '1' ,
count(*) , 'Serial'fromall_tableswhere ( trim(degree) ='1'ortrim(degree) ='0' ) and( trim(instances) ='1'ortrim(instances) ='0' )
groupbyowner)
orderbyowner;


📢 注意: 如果查询出 Parallel 列的值为 Serial 就证明并行度都是 1,为正常。

该 SQL 检查当前数据库中所有用户中存在不同并行度的 索引:


setpagesize1000RemHowmanyindexesauserhavewithdifferentDOPsRem---------------------------------------------------;
select*from (
selectsubstr(owner,1,15) Owner ,
substr(trim(degree),1,7) Degree ,
substr(trim(instances),1,9) Instances ,
count(*) "Num Indexes",
'Parallel'fromall_indexeswhere ( trim(degree) !='1'andtrim(degree) !='0' ) or( trim(instances) !='1'andtrim(instances) !='0' )
groupbyowner, degree , instancesunionselectsubstr(owner,1,15) owner , '1' , '1' ,
count(*) , 'Serial'fromall_indexeswhere ( trim(degree) ='1'ortrim(degree) ='0' ) and( trim(instances) ='1'ortrim(instances) ='0' )
groupbyowner)
orderbyowner;


📢 注意: 如果查询出 Parallel 列的值为 Serial 就证明并行度都是 1,为正常。

该 SQL 检查具有不同 DOP 的索引的表:


coltable_nameformata35colindex_nameformata35RemTablesthathaveIndexeswithnotthesameDOPRem!!!!!Thiscommandcantakesometimetoexecute!!!Rem---------------------------------------------------;
setlines150selectsubstr(t.owner,1,15) Owner ,
t.table_name ,
substr(trim(t.degree),1,7) Degree ,
substr(trim(t.instances),1,9) Instances,
i.index_name ,
substr(trim(i.degree),1,7) Degree ,
substr(trim(i.instances),1,9) Instancesfromall_indexesi,
all_tablestwhere ( trim(i.degree) !=trim(t.degree) ortrim(i.instances) !=trim(t.instances) ) andi.owner=t.ownerandi.table_name=t.table_name;


📢 注意:查询结果为空代表没有不同 DOP 的索引的表,正常。

相关文章
|
消息中间件 关系型数据库 Kafka
OBCP第七章 OB迁移、备份与恢复-迁移服务
OBCP第七章 OB迁移、备份与恢复-迁移服务
805 0
|
NoSQL 安全 Redis
Redis6.0新特性——ACL(权限控制列表)实现限制用户可执行命令和KEY
Redis6.0新特性——ACL(权限控制列表)实现限制用户可执行命令和KEY
1277 0
|
7月前
|
弹性计算 数据挖掘 测试技术
阿里云服务器带宽怎么选?1M/3M/5M/10M价格介绍与选购省钱技巧
本文介绍了2026年阿里云服务器带宽的计费方式与选购策略。阿里云提供固定带宽(包月/包年)和按流量计费两种模式,带宽独享且价格随档位非线性增长。以热门的经济型e实例(99元/年,3M固定带宽)和通用算力型u1实例(199元/年,5M固定带宽)为例,详细对比了1M至10M带宽的年付成本差异。文章建议用户根据业务流量模型合理选配,优先通过官方活动入口购买以享折扣,善用优惠券实现折上折,并选择"续费同价"产品保障长期成本可控,避免因初期选择低带宽而导致后期付出更高升级代价。
|
11月前
|
人工智能 JSON 网络协议
AI 大模型 LLM API 架构:Gemini 3.0 Pro 原生多模态能力的边界与工程落地
随着 Model-as-a-Service (MaaS) 的普及,如何在受限网络环境下构建高可靠的 GenAI 应用成为工程挑战。本文将分析 Gemini 3.0 Pro 的 Native Multimodal 架构特性,并探讨基于 n1n.ai 聚合网关(Aggregation Gateway)的跨区域调用方案。
626 1
AI 大模型 LLM API 架构:Gemini 3.0 Pro 原生多模态能力的边界与工程落地
|
9月前
|
人工智能 安全 Linux
OpenClaw云端+本地搭建使用教程:阿里云/AWS对接大模型API、百炼Coding Plan配置与避坑大全
OpenClaw(Clawdbot)作为主流AI自动化编排框架,自身不内置大模型推理能力,必须对接外部LLM API才能实现智能对话、定时任务、自动化工作流等核心能力。很多用户在部署时普遍遇到:云服务器选型踩坑、API对接失败、密钥泄露风险、跨平台环境异常、费用失控等问题。本文基于2026年最新实践,完整覆盖**阿里云、AWS两大云平台部署**、**MacOS/Linux/Windows11本地安装**、**阿里云百炼Coding Plan免费API配置**,附带可直接复制的命令行、配置文件与高频问题解决方案,实现从环境搭建到模型对接的全流程落地。
1240 3
|
12月前
|
存储 弹性计算 架构师
年度账单分析:资深架构师教你五个步骤降低30%云资源成本
企业上云后成本飙升?资深架构师揭秘实战“五步降本法”:从成本可视化、计算资源优化,到存储、网络治理,最终通过架构革新实现持续降本。系统化策略助你降低30%以上云支出,将云计算从成本负担转变为高效引擎。(238字)
|
12月前
|
存储 弹性计算 监控
云账单分析与优化工具使用
本指南系统介绍云账单分析与优化工具的使用方法,涵盖账单解析、成本分摊、预算管理、资源优化等核心模块,助力企业实现云成本可视化、精细化管控,通过标签体系、智能建议与多账号协同,推动从“被动付费”到“主动治理”的转型,最大化释放云上成本优化潜力。(238字)
539 0
|
弹性计算 运维 安全
阿里云操作系统迁移最佳实践|飞天技术沙龙-CentOS 迁移替换专场
本次方案的主题是阿里云操作系统迁移最佳实践,Alibaba Cloud Linux /Anolis OS 兼容 CentOS 生态,因此能够很丝滑的进行迁移替换。无论是对企业的运维人员,还是对企业操作系统的使用者来说,相对简化了它的维护成本。通过 SMC 操作系统迁移实践带用户深入了解,不仅阐述了原地迁移方案的独特优势,还针对不同的迁移场景,逐步剖析了整个迁移流程,力求使复杂的操作变得直观易懂,实现了真正的“白屏化”体验。 1. CentOS 迁移背景 2. 操作系统迁移实践 3. 迁移故障处理
799 2
|
监控 NoSQL Redis
Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.
Asynchronous AOF fsync is taking too long (disk is busy?). Writing the AOF buffer without waiting for fsync to complete, this may slow down Redis.