oracle多cpu并行查询

来源:互联网 发布:ibm数据库 编辑:程序博客网 时间:2024/04/28 22:15

t_medflow  表拥有1千万数据 FlowId是主键 拥有主键索引

统计总数量

select count(FLOWID) from t_medflow t

用时:1.5秒

select count(*) from t_medflow t

用时:1.46秒

多次测试效率差不多

 

添加条件查询

select count(FLOWID) from t_medflow t where pname like '%中%'

用时:25S   [对与一个查询来说统计总数量就用了25秒,基本用户体验极差]

 

分析统计下表 防止走错的执行计划

ANALYZE TABLE t_medflow COMPUTE STATISTICS;

在查

select count(FLOWID) from t_medflow t where pname like '%中%'

用时:22秒

 

使用多cpu并行处理

select /*+ PARALLEL(t_medflow,14)  */ count(*) from t_medflow
where pname like '%中%'

用时 :1.7秒 [我的数据库环境是4CPU]

解决count(*)慢的问题了

cpu设置的数量根据实际cpu的数量定  不要超过4倍cpu 反而效率低

 

使用索引 并行效率很低 不知道什么问题

select /*+ PARALLEL_INDEX(t_medflow, PK_FLOWID, 10)   */ count(*) from t_medflow
where pname like '%中%'