SQL优化案例一则,insert到临时表的sql优化余地
来源:互联网 发布:软件广告语 编辑:程序博客网 时间:2024/05/06 06:18
问题SQL,报上来看有没优化的余地。
9i的t0epcis库,
这个sql是上生产了,但是没有开quartz开关;所以这次上线将会打开,需要优化该sql;请协助支持!
INSERT /* +APPEND */ INTO ECIF_GROP_DEPART_ADD_TMP
select distinct /*+ parallel(o,8)*/ o.created_by,o.created_date,o.updated_by,o.updated_date,
o.client_no,
o.client_name,
o.org_code_no,
o.tax_no,
o.business_register_no,
o.other_certificate_no,
o.address,
n.department_code,
o.client_no||n.department_code as rel_no,
o.updated_date as add_date,
'0'
from ecif_client_organization_info o ,cicsdata.ecif_policy_client_relation n
where o.client_no=n.client_no(+) and o.updated_date >= to_date('2014-03-10','yyyy-mm-dd')
and o.updated_date<(to_date('2014-03-10','yyyy-mm-dd')+1) AND n.department_code is not null
执行计划:
驱动表:
Cicsdata.ecif_client_organization_info
2g,hash分区表,分区键是CLIENT_NO
驱动表行数不多,才28行,走nest loop没问题。
select count(*) from ecif_client_organization_info o where o.updated_date >= to_date('2014-03-10','yyyy-mm-dd') and o.updated_date<(to_date('2014-03-10','yyyy-mm-dd')+1)
--28
被驱动表
CICSDATA.ECIF_POLICY_CLIENT_RELATION表
统计信息:343567876行,2011年3月11日采集。
实际:该表145G。
IX_ECIF_P_C_RELATION_C_NO_ROLE索引
统计信息:342787981行,聚簇因子:302798887
38G,复合b*tree索引,(CLIENT_NO,CLIENT_ROLE)
总结:
关于Hint改进的意见:
Parallel hint没用得上,这里走索引不能用这个hint,这个hint是并行表的。
Append hint 改成/*+APPEND */,*与+之间别有空格。
如果还想有所改进,可以在CICSDATA.ECIF_POLICY_CLIENT_RELATION表建单列索引(CLIENT_NO),但是必要性不是很大,建多了索引也有维护成本。
另外该索引可以尝试重建,重建完clustering_factor会变小,对随机读取有帮助。
改进完后,执行计划。
INSERT /*+APPEND */ INTO ECIF_GROP_DEPART_ADD_TMP
select distinct o.created_by,o.created_date,o.updated_by,o.updated_date,
o.client_no,
o.client_name,
o.org_code_no,
o.tax_no,
o.business_register_no,
o.other_certificate_no,
o.address,
n.department_code,
o.client_no||n.department_code as rel_no,
o.updated_date as add_date,
'0'
from ecif_client_organization_info o ,cicsdata.ecif_policy_client_relation n
where o.client_no=n.client_no(+) and o.updated_date >= to_date('2014-03-10','yyyy-mm-dd')
and o.updated_date<(to_date('2014-03-10','yyyy-mm-dd')+1) AND n.department_code is not null
- SQL优化案例一则,insert到临时表的sql优化余地
- SQL优化案例一则
- Oracle SQL 'or' 的优化,最近的案例一则。
- 一则sql优化的例子
- SQL优化一则
- 利用临时表优化SQL
- 区间检索SQL优化一则
- 一个sql优化的案例
- sql优化-典型案例
- SQL优化案例(1)
- SQL优化案例
- SQL优化案例-1
- SQL优化案例1
- SQL优化案例150811
- SQL优化案例150812
- SQL优化一则:灵活运用字段的选择性
- 【SQL优化】四月份培训的一个sql优化案例1
- 【SQL优化】四月份培训的一个sql优化案例2
- xml学习笔记
- 万能的XML
- 安装log4cxx
- 【网络流】CEOI2009 all
- Algorithm学习笔记 --- 分数拆分简单枚举
- SQL优化案例一则,insert到临时表的sql优化余地
- vim教程
- 单例模式
- mini2440 tiny6410开发板网络设置(永久改变,重启后不恢复)
- iOS开发常用的网站
- java+jboss消息服务开发简单例子
- JDBC的四种连接方式
- tiny6410 U盘问题
- getline()函数