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 计划自动创建数据库分区 固定增量的数据,自动创建 ...
随机推荐
- spark任务调度模式,动态资源分配
官网链接: http://spark.apache.org/docs/latest/job-scheduling.html 主要介绍: 1 application级调度方式 2 单个applicati ...
- SpringMVC 源码解析
前言 年初面试时接触到一道面试题,在聊到SpringMVC时提到了SpringMVC的开发者为何要设计父子容器呢,又或者说是父子容器的设计有什么更实际的作用呢? 首先 ...
- 【数据结构】8.java源码关于HashMap
1.hashmap的底层数据结构 众所皆知map的底层结构是类似邻接表的结构,但是进入1.8之后,链表模式再一定情况下又会转换为红黑树在JDK8中,当链表长度达到8,并且hash桶容量超过64(MIN ...
- 如何让springboot打包的项目部署在阿里云上使用https和http方式访问
前言 问题描述:怎么让springboot部署在服务器上使用https协议方式访问我们的接口或者域名,目的是某些平台请求的是https协议,而不是https 部署环境:阿里云 centos7服务器,s ...
- jQuery Validate 可选项
- springBoot与Swagger2的整合
1.在项目pom文件中引入swagger2的jar包 <!-- swagger2开始 --> <dependency> <groupId>io.springfox& ...
- Spring入门(十一):Spring AOP使用进阶
在上篇博客中,我们了解了什么是AOP以及在Spring中如何使用AOP,本篇博客继续深入讲解下AOP的高级用法. 1. 声明带参数的切点 假设我们有一个接口CompactDisc和它的实现类Blank ...
- 【转】python爬虫之腾讯视频vip下载
本文转自如下:作者:jia666666 原文:https://blog.csdn.net/jia666666/article/details/82466553 版权声明:本文为博主原创文章,转载请附上 ...
- win命令获取外网ip
win命令: chcp 65001 curl https://ip.cn bat: @echo offchcp 65001 && curl https://ip.cnpause 链接: ...
- SpringBoot第二十四篇:应用监控之Admin
作者:追梦1819 原文:https://www.cnblogs.com/yanfei1819/p/11457867.html 版权声明:本文为博主原创文章,转载请附上博文链接! 引言 前一章(S ...