表和索引的并发深度报告
目的:
为DBA提供一些脚本去检查表和索引上的并发深度
适用范围和应用
数据库管理员,研发人员和架构分析师
检查脚本
系统有多少个CPU,默认的并发深度是Default = parallel_threads_per_cpu * cpu_count。可以通过select substr(name,1,30) Name , substr(value,1,5) Value from v$parameter where name in ('parallel_threads_per_cpu' , 'cpu_count' );获得系统中并发深度,系统CPU个数。
通常情况下DOP:=degree*instances。看下面的笔记得到更精确的算法公式。在NOTE 260845中可以看到老的和新的设置并发深度的语法。
Sql select * from (
select substr(owner,1,15) Owner , ltrim(degree) Degree,
ltrim(instances) Instances,
count(*) "Num Tables" , 'Parallel'
from all_tables
where ( trim(degree) != '1' and trim(degree) != '0' ) or
( trim(instances) != '1' and trim(instances) != '0' )
group by owner, degree , instances
union
select substr(owner,1,15) owner , '1' , '1' ,
count(*) , 'Serial'
from all_tables
where ( trim(degree) = '1' or trim(degree) != '0' ) and
( trim(instances) != '1' or trim(instances) != '0' )
group by owner
)
order by owner; 可以查看系统中用户拥有的表个数和表的不同并发深度设置
Sql select * from (
select substr(owner,1,15) Owner ,
substr(trim(degree),1,7) Degree ,
substr(trim(instances),1,9) Instances ,
count(*) "Num Indexes",
'Parallel'
from all_indexes
where ( trim(degree) != '1' and trim(degree) != '0' ) or
( trim(instances) != '1' and trim(instances) != '0' )
group by owner, degree , instances
union
select substr(owner,1,15) owner , '1' , '1' ,
count(*) , 'Serial'
from all_indexes
where ( trim(degree) = '1' or trim(degree) != '0' ) and
( trim(instances) != '1' or trim(instances) != '0' )
group by owner
)
order by owner; 查看系统中用户拥有的索引个数和索引的不同并发深度设置
有索引的表有不同的并发深度,下面的sql语句可能会执行一段时间
Sql set lines 150
select substr(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) Instances
from all_indexes i,
all_tables t
where ( trim(i.degree) != trim(t.degree) or
trim(i.instances) != trim(t.instances) ) and
i.owner = t.owner and
i.table_name = t.table_name; 检索用户名称,表名,深度,实例个数,索引名称