GS-PON数据库分区列范围查询优化案例
查询慢的SQL:
with p as(select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerrorfrom perf_t_ponport p,device d, node c,node npwhere p.resid = d.deviceidand d.nodecode = c.nodecodeand c.citynodecode = np.nodecodeand c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = 'admin' AND S.AUTHTYPE = 'VIEW')and d.changetype = 0and p.coltime between trunc(sysdate-1,'dd') and trunc(sysdate,'dd')and p.rxcrcerror is not nulland p.rxcrcerror >0order by p.rxcrcerror desc)select *from pwhere rownum <=10
SQL> explain plan for with p as(2 select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerror3 from perf_t_ponport p,device d, node c,node np4 where p.resid = d.deviceid5 and d.nodecode = c.nodecode6 and c.citynodecode = np.nodecode7 and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = 'admin' AND S.AUTHTYPE = 'VIEW')8 and d.changetype = 09 and p.coltime between trunc(sysdate-1,'dd') and trunc(sysdate,'dd')10 and p.rxcrcerror is not null11 and p.rxcrcerror >012 order by p.rxcrcerror desc13 )14 select *15 from p16 where rownum <=1017 ;已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 733587010----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 10 | 3430 | 1125K (19)| 03:45:09 | | ||* 1 | COUNT STOPKEY | | | | | | | || 2 | VIEW | | 133 | 45619 | 1125K (19)| 03:45:09 | | ||* 3 | SORT ORDER BY STOPKEY | | 133 | 22743 | 1125K (19)| 03:45:09 | | ||* 4 | FILTER | | | | | | | ||* 5 | HASH JOIN | | 133 | 22743 | 1125K (19)| 03:45:09 | | ||* 6 | HASH JOIN SEMI | | 133 | 19950 | 1125K (19)| 03:45:08 | | ||* 7 | HASH JOIN | | 219 | 28251 | 1125K (19)| 03:45:08 | | || 8 | NESTED LOOPS | | 219 | 25185 | 1125K (19)| 03:45:08 | | || 9 | PARTITION RANGE ITERATOR | | 219 | 10074 | 1125K (19)| 03:45:03 | KEY | KEY ||* 10 | TABLE ACCESS FULL | PERF_T_PONPORT | 219 | 10074 | 1125K (19)| 03:45:03 | KEY | KE| 11 | TABLE ACCESS BY INDEX ROWID| DEVICE | 1 | 69 | 2 (0)| 00:00:01 | ||* 12 | INDEX UNIQUE SCAN | PK_DEVICE | 1 | | 1 (0)| 00:00:01 | || 13 | TABLE ACCESS FULL | NODE | 1214 | 16996 | 8 (0)| 00:00:01 | | ||* 14 | INDEX RANGE SCAN | SYS_C00543203 | 1167 | 24507 | 10 (0)| 00:00:01 | || 15 | TABLE ACCESS FULL | NODE | 1214 | 25494 | 8 (0)| 00:00:01 | |----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------1 - filter(ROWNUM<=10)3 - filter(ROWNUM<=10)4 - filter(TRUNC(SYSDATE@!-1,'fmdd')<=TRUNC(SYSDATE@!,'fmdd'))5 - access("C"."CITYNODECODE"="NP"."NODECODE")6 - access("C"."NODECODE"="S"."NODECODE")7 - access("D"."NODECODE"="C"."NODECODE")10 - filter("P"."RXCRCERROR" IS NOT NULL AND "P"."RXCRCERROR">0 AND"P"."COLTIME">=TRUNC(SYSDATE@!-1,'fmdd') AND "P"."COLTIME"<=TRUNC(SYSDATE@!,'fmdd'))12 - access("P"."RESID"="D"."DEVICEID" AND "D"."CHANGETYPE"=0)14 - access("S"."NETUSERID"='admin' AND "S"."AUTHTYPE"='VIEW')已选择36行。
with p as(select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerrorfrom perf_t_ponport p,device d, node c,node npwhere p.resid = d.deviceidand d.nodecode = c.nodecodeand c.citynodecode = np.nodecodeand d.changetype = 0and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = 'admin' AND S.AUTHTYPE = 'VIEW')and (p.coltime =trunc(sysdate-1,'dd') or p.coltime =trunc(sysdate,'dd') )and p.rxcrcerror is not nulland p.rxcrcerror >0order by p.rxcrcerror desc)select *from pwhere rownum <=10;
SQL> explain plan for with p as(2 select np.nodecode , np.nodename, d.deviceid, d.devicename, d.loopaddress, p.respara, p.rxcrcerror, p.txcrcerror3 from perf_t_ponport p,device d, node c,node np4 where p.resid = d.deviceid5 and d.nodecode = c.nodecode6 and c.citynodecode = np.nodecode7 and d.changetype = 08 and c.nodecode in (SELECT S.NODECODE FROM SINGLEUSERNODEAUTH S WHERE S.NETUSERID = 'admin' AND S.AUTHTYPE = 'VIEW')9 and (p.coltime =trunc(sysdate-1,'dd') or p.coltime =trunc(sysdate,'dd') )10 and p.rxcrcerror is not null11 and p.rxcrcerror >012 order by p.rxcrcerror desc13 )14 select *15 from p16 where rownum <=10;已解释。SQL>SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 2287749996----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 10 | 3430 | 915 (2)| 00:00:11 | | ||* 1 | COUNT STOPKEY | | | | | | | || 2 | VIEW | | 266 | 91238 | 915 (2)| 00:00:11 | | ||* 3 | SORT ORDER BY STOPKEY | | 266 | 45486 | 915 (2)| 00:00:11 | | ||* 4 | HASH JOIN | | 266 | 45486 | 915 (2)| 00:00:11 | | || 5 | TABLE ACCESS FULL | NODE | 1214 | 25494 | 8 (0)| 00:00:01 | | ||* 6 | HASH JOIN RIGHT SEMI | | 267 | 40050 | 905 (2)| 00:00:11 | | ||* 7 | INDEX RANGE SCAN | SYS_C00543203 | 1167 | 24507 | 10 (0)| 00:00:01 | ||* 8 | HASH JOIN | | 437 | 56373 | 895 (2)| 00:00:11 | | || 9 | TABLE ACCESS FULL | NODE | 1214 | 16996 | 8 (0)| 00:00:01 | | || 10 | NESTED LOOPS | | 437 | 50255 | 885 (2)| 00:00:11 | | || 11 | PARTITION RANGE INLIST | | 437 | 20102 | 2 (0)| 00:00:01 |KEY(I) |KEY(I) ||* 12 | TABLE ACCESS FULL | PERF_T_PONPORT | 437 | 20102 | 2 (0)| 00:00:01 |KEY(I) |KEY(I)| 13 | TABLE ACCESS BY INDEX ROWID| DEVICE | 1 | 69 | 2 (0)| 00:00:01 | | ||* 14 | INDEX UNIQUE SCAN | PK_DEVICE | 1 | | 1 (0)| 00:00:01 | | |----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------1 - filter(ROWNUM<=10)3 - filter(ROWNUM<=10)4 - access("C"."CITYNODECODE"="NP"."NODECODE")6 - access("C"."NODECODE"="S"."NODECODE")7 - access("S"."NETUSERID"='admin' AND "S"."AUTHTYPE"='VIEW')8 - access("D"."NODECODE"="C"."NODECODE")12 - filter("P"."RXCRCERROR" IS NOT NULL AND "P"."RXCRCERROR">0 AND("P"."COLTIME"=TRUNC(SYSDATE@!-1,'fmdd') OR "P"."COLTIME"=TRUNC(SYSDATE@!,'fmdd')))14 - access("P"."RESID"="D"."DEVICEID" AND "D"."CHANGETYPE"=0)已选择34行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime <trunc(sysdate,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 4015217925----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | || 1 | PARTITION RANGE ITERATOR| | 100 | 4600 | 2 (0)| 00:00:01 | 1 | KEY ||* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 1 | KEY |----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------2 - filter("P"."COLTIME"<TRUNC(SYSDATE@!,'fmdd'))已选择14行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime > trunc(sysdate-1,'dd') and p.coltime <trunc(sysdate,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 1162550374----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 1637 (37)| 00:00:20 | | ||* 1 | FILTER | | | | | | | || 2 | PARTITION RANGE ITERATOR| | 100 | 4600 | 1637 (37)| 00:00:20 | KEY | KEY ||* 3 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 1637 (37)| 00:00:20 | KEY |----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------1 - filter(TRUNC(SYSDATE@!-1,'fmdd')<TRUNC(SYSDATE@!,'fmdd'))3 - filter("P"."COLTIME">TRUNC(SYSDATE@!-1,'fmdd') AND "P"."COLTIME"<TRUNC(SYSDATE@!,'fmdd'))已选择16行。
SQL> explain plan for select * from perf_t_ponport partition(P_20170307) p;已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 1021280532----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | || 1 | PARTITION RANGE SINGLE| | 100 | 4600 | 2 (0)| 00:00:01 | 85 | 85 || 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 85 |----------------------------------------------------------------------------------------------------已选择9行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime = trunc(sysdate-1,'dd') and p.coltime <trunc(sysdate,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 506920385----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 8 (25)| 00:00:01 | | ||* 1 | FILTER | | | | | | | || 2 | PARTITION RANGE SINGLE| | 100 | 4600 | 8 (25)| 00:00:01 | KEY | KEY ||* 3 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 8 (25)| 00:00:01 | KEY | KE----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------1 - filter(TRUNC(SYSDATE@!-1,'fmdd')<TRUNC(SYSDATE@!,'fmdd'))3 - filter("P"."COLTIME"=TRUNC(SYSDATE@!-1,'fmdd') AND "P"."COLTIME"<TRUNC(SYSDATE@!,'fmdd'))已选择16行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime = trunc(sysdate-1,'dd') or p.coltime = trunc(sysdate,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 2473962793----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | || 1 | PARTITION RANGE INLIST| | 100 | 4600 | 2 (0)| 00:00:01 |KEY(I) |KEY(I) ||* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 |KEY(I) |KEY(I)----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------2 - filter("P"."COLTIME"=TRUNC(SYSDATE@!-1,'fmdd') OR "P"."COLTIME"=TRUNC(SYSDATE@!,'fmdd'))已选择14行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime >trunc(sysdate-1,'dd') or p.coltime < trunc(sysdate-5,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 3647984539----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 100 | 4600 | 2 (0)| 00:00:01 | | || 1 | PARTITION RANGE ALL| | 100 | 4600 | 2 (0)| 00:00:01 | 1 | 101 ||* 2 | TABLE ACCESS FULL | PERF_T_PONPORT | 100 | 4600 | 2 (0)| 00:00:01 | 1 | 101 |----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------2 - filter("P"."COLTIME"<TRUNC(SYSDATE@!-5,'fmdd') OR"P"."COLTIME">TRUNC(SYSDATE@!-1,'fmdd'))已选择15行。
SQL> explain plan for select * from perf_t_ponport p where p.coltime >trunc(sysdate-1,'dd') or p.coltime < trunc(sysdate-5,'dd');已解释。SQL> select * from table(dbms_xplan.display);PLAN_TABLE_OUTPUT----------------------------------------------------------------------------------------------------Plan hash value: 470656424----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 1512M| 67G| 3783K (3)| 12:36:37 | | || 1 | PARTITION RANGE OR| | 1512M| 67G| 3783K (3)| 12:36:37 |KEY(OR)|KEY(OR)||* 2 | TABLE ACCESS FULL| PERF_T_PONPORT | 1512M| 67G| 3783K (3)| 12:36:37 |KEY(OR)|KEY(OR)|----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):---------------------------------------------------2 - filter("P"."COLTIME"<TRUNC(SYSDATE@!-5,'fmdd') OR"P"."COLTIME">TRUNC(SYSDATE@!-1,'fmdd'))Note------ 'PLAN_TABLE' is old version已选择19行。
GS-PON数据库分区列范围查询优化案例的更多相关文章
- MySql学习(六) —— 数据库优化理论(二) —— 查询优化技术
逻辑查询优化包括的技术 1)子查询优化 2)视图重写 3)等价谓词重写 4)条件简化 5)外连接消除 6)嵌套连接消除 7)连接消除 8)语义优化 9)非SPJ优化 一.子查询优化 1. ...
- (转)mysql水平分表和垂直分表和数据库分区
坚信数据库的物理设计在对高级数据库的性能影响上远比其他因素重要.给大家说一下经过专家对Oracle的研究,他们解释了为什么拙劣的物理设计是数据库停机(无论是有计划的还是没计划的)背后的主要原因.但在这 ...
- MySQL数据库分区的概念与2大好处(1)
我们大家都知道通过MySQL数据库分区(Partition)可以提升MySQL数据库的性能,那么到底什么是MySQL数据库分区呢?以及其实际应用的好处的表现有哪些呢?以下的文章就是对这些内容的描述. ...
- mysql数据库分区功能及实例详解
分区听起来怎么感觉是硬盘呀,对没错除了硬盘可以分区数据库现在也支持分区了,分区可以解决大数据量的处理问题,下面一起来看一个mysql数据库分区功能及实例详解 一,什么是数据库分区 前段时间写过一篇 ...
- DB2 9.5 数据库分区管理及应用实践
DB2 数据库分区是 DB2 企业版 DPF(Data Partitioning Feature)选件提供的,它主要用来为大规模数据处理.高并发数据访问提供支持.DB2 数据库分区采用 Share-n ...
- Atitit.数据库分区的设计 attilax 总结
Atitit.数据库分区的设计 attilax 总结 1. 分区就是分门别类的文件夹 (what)1 2. 分区的好处(y)1 3. 分区原则(要不要分区,何时分区)how2 4. 主要的分表类型有 ...
- SqlServer数据库分区
在最近的项目中,在尽可能优化了sql语句后,上层仍要求对数据库进行优化,因为考虑到系统上线后数据量会非常庞大,而且这些个表的数据都有明显的时间划分,于是就引入了数据库分区的概念.摘用百度百科的定义,数 ...
- MSSQL 2005 列转行应用案例
/*MSSQL 2005 列转行应用案例 By claro(陈亮) 2008-12-2 转载请包含此信息*/ --test table KuCunMX If object_id ('KuCunMX') ...
- sql2008 计划自动创建数据库分区【转】
本文转自:http://jingyan.baidu.com/article/6b97984d9a26ec1ca3b0bf77.html sql2008 计划自动创建数据库分区 固定增量的数据,自动创建 ...
随机推荐
- 性能测试学习第四天-----loadrunner:jdbc批量制造测试数据 & controller应用
Javavuser协议 1.过程概述:在eclipse中用java编写sql执行脚本,复制到lr中,调整后通过参数化迭代批量制造测试数据: 2.步骤: 1).在eclipse中新建java proje ...
- Go 语言基础——错误处理
#### 学习目标 掌握错误处理 掌握自定义错误处理 掌握defer关键字的使用 ------ #### 错误处理 GO没有异常处理机制 Go语言引入了一个关于错误处理的标准模式,即error接口,该 ...
- net core Webapi基础工程搭建(三)——在线接口文档Swagger
目录 前言 Swagger NuGet引用第三方类库 别急,还有 没错,注释 小结 前言 前后分离的好处,就是后端埋头做业务逻辑功能,不需要过多考虑用户体验,只专注于数据.性能开发,对于前端需要的数据 ...
- Spring源码剖析7:AOP实现原理详解
前言 前面写了六篇文章详细地分析了Spring Bean加载流程,这部分完了之后就要进入一个比较困难的部分了,就是AOP的实现原理分析.为了探究AOP实现原理,首先定义几个类,一个Dao接口: pub ...
- Delphi - Indy TIdFTPServer封装类
在Delphi 7开发下有强大的Indy控件,版本为9,要实现一个FTP服务器,参考自带的例子,发现还要写很多函数,而且不支持中文显示文件列表等等. 于是,自己改进封装了下,形成一个TFTPServe ...
- EOJ 2019.2月赛 D. 进制转换
https://acm.ecnu.edu.cn/contest/140/problem/D/ 题意 求一个区间L,R中,在K进制表示下末尾恰有m个0的数字个数. 思路 末尾有m个0,就表示的是K^m的 ...
- codeforces 389 D. Fox and Minimal path(构造+思维)
题目链接:https://vjudge.net/contest/175446#problem/J 题解:显然要用最多n个点构成的图要使的得到的最短路条数有1e9次个,显然要有几个数相乘容易想到2的几进 ...
- codeforces 779 D. String Game(二分)
题目链接:http://codeforces.com/contest/779/problem/D 题意:给你一段操作序列,按顺序依次删掉字符串1中相应位置的字符,问你最多能按顺序删掉多少个字符,使得s ...
- hdu 2844 Coins 多重背包(模板) *
Coins Time Limit: 2000/1 ...
- Python起源发展与学(ru)习(keng)的开篇
写在前面,python天下第一!!!!!我要做python的舔狗