- 浏览: 448330 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (229)
- gef (1)
- emf (0)
- rcp (2)
- 杂谈 (3)
- draw2d (2)
- xml (1)
- spring (16)
- osgi (1)
- jsp (6)
- hibernate (8)
- j2se (41)
- oracle (25)
- js (23)
- ognl (1)
- struts2 (2)
- webwork (1)
- prototype (1)
- dwr (3)
- struts (7)
- axis2 (3)
- axis1 (6)
- lucene (9)
- pop3 (1)
- aspectj (1)
- 网络协议 (6)
- bat (6)
- Quartz (5)
- jms (3)
- jndi (7)
- 网络爬虫 (7)
- acegi (1)
- linux (5)
- 缓存 (1)
- mysql (1)
- 在使用Java处理图形应用时,经常有人推荐设置 -Djava.awt.headless=true,具体含义和效果查了一下,记录在这里分享 Headless模式是系统的一种配置模式。在该模式下,系统缺少了显示设备、键盘或鼠标。 Headless模式虽然不是我们愿意见到的,但事实上我们却常常需要在该模式下工作,尤其是服务器端程序开发者。因为服务器(如提供Web服务的主机)往往可能缺少前述设备,但又需要使用他们提供的功能,生成相应的数据,以提供给客户端(如浏览器所在的配有相关的显示设备、键盘和鼠标的主 (1)
最新评论
-
hanmiao:
注释掉的那壹行少了壹個斜线,楼主...
servlet导出excel -
天下无贼:
Thread.Interrupt方法,只是通过扔出异常的方式, ...
Java Thread.interrupt 害人! 中断JAVA线程(zz) -
天下无贼:
呵呵,是你自己写错了。
Java Thread.interrupt 害人! 中断JAVA线程(zz) -
MO_ZHUANG_D:
如果是真的就感激不尽了
Axure RP教程 -
小嘴冰凉:
在开始执行的时候,如果是数据库存储,程序会从数据库中查job信 ...
quartz的持久化
嵌套SQL的查询速度比较分析
- 博客分类:
- oracle
嵌套SQL的查询速度比较分析
文章中使用Oracle自带的HR数据库,故代码可以直接进行测试。
代码一:
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
or t.first_name like 'B%'
or t.first_name like 'H%'
or t.first_name like 'K%'
or t.first_name like 'M%'
or t.first_name like 'J%'
or t.first_name like 'N%'
执行计划:
代码二:
select *
from (
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
or t.first_name like 'B%'
or t.first_name like 'H%'
or t.first_name like 'K%'
or t.first_name like 'M%'
or t.first_name like 'J%'
or t.first_name like 'N%'
)
执行计划:
对比:代码1与代码2的执行计划相同
代码三:
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'B%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'H%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'K%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'M%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'J%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'N%'
执行计划:
代码四:
select * from
(
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'B%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'H%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'K%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'M%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'J%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'N%'
)
执行计划:
对比:代码4中Sort Unique与代码3的执行计划相同。但Oracle在处理代码4的查询语句时,构建了一个内部视图来整理查询结果,其中需要21次IO操作,故需要更长的时间。
其他:在一个SQL中,使用“OR”语句比使用多个Union会花费更短的时间。
代码五:
代码5-1:
select *
from
(select * from HR.Employees tx where tx.department_id = 50) T1,
(select * from HR.Departments ty where ty.department_id < 150) T2
where t1.department_id = t2.department_id
代码5-2:
select *
from
HR.Employees t1,
HR.Departments T2
where t1.department_id = t2.department_id and t1.department_id = 50 and t2.department_id < 150
代码5-3:
select *
from
HR.Employees T1,
HR.Departments T2
where t1.department_id = t2.department_id(+) and t1.department_id = 50 and t2.department_id <150
代码5-4:
select *
from
HR.Employees T1,
HR.Departments T2
where t1.department_id(+) = t2.department_id and t1.department_id = 50 and t2.department_id <150
代码5-1到代码5-4的Oracle执行计划分析结果相同:
对比:代码5-1到代码5-4的执行计划相同。Oracle是先对T1和T2中数据进行过滤后,再对结果集进行关联查询。且Oracle对表过滤内容进行了优化,对表Departments的查询优化为 TY.Department_ID=50 而不是 TY.Department_ID<150
http://www.cnblogs.com/joyyuan97/archive/2008/09/13/516333.html
文章中使用Oracle自带的HR数据库,故代码可以直接进行测试。
代码一:
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
or t.first_name like 'B%'
or t.first_name like 'H%'
or t.first_name like 'K%'
or t.first_name like 'M%'
or t.first_name like 'J%'
or t.first_name like 'N%'
执行计划:
代码二:
select *
from (
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
or t.first_name like 'B%'
or t.first_name like 'H%'
or t.first_name like 'K%'
or t.first_name like 'M%'
or t.first_name like 'J%'
or t.first_name like 'N%'
)
执行计划:
对比:代码1与代码2的执行计划相同
代码三:
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'B%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'H%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'K%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'M%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'J%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'N%'
执行计划:
代码四:
select * from
(
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'A%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'B%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'H%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'K%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'M%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'J%'
union
select t.employee_id, t.first_name, t.phone_number from HR.Employees t where t.first_name like 'N%'
)
执行计划:
对比:代码4中Sort Unique与代码3的执行计划相同。但Oracle在处理代码4的查询语句时,构建了一个内部视图来整理查询结果,其中需要21次IO操作,故需要更长的时间。
其他:在一个SQL中,使用“OR”语句比使用多个Union会花费更短的时间。
代码五:
代码5-1:
select *
from
(select * from HR.Employees tx where tx.department_id = 50) T1,
(select * from HR.Departments ty where ty.department_id < 150) T2
where t1.department_id = t2.department_id
代码5-2:
select *
from
HR.Employees t1,
HR.Departments T2
where t1.department_id = t2.department_id and t1.department_id = 50 and t2.department_id < 150
代码5-3:
select *
from
HR.Employees T1,
HR.Departments T2
where t1.department_id = t2.department_id(+) and t1.department_id = 50 and t2.department_id <150
代码5-4:
select *
from
HR.Employees T1,
HR.Departments T2
where t1.department_id(+) = t2.department_id and t1.department_id = 50 and t2.department_id <150
代码5-1到代码5-4的Oracle执行计划分析结果相同:
对比:代码5-1到代码5-4的执行计划相同。Oracle是先对T1和T2中数据进行过滤后,再对结果集进行关联查询。且Oracle对表过滤内容进行了优化,对表Departments的查询优化为 TY.Department_ID=50 而不是 TY.Department_ID<150
http://www.cnblogs.com/joyyuan97/archive/2008/09/13/516333.html
发表评论
-
Oracle reverse函数
2011-12-08 13:56 1987Oracle reverse函数 2007-10-25 14: ... -
教你快速掌握Oracle数据库中的like优化-性能调优
2011-12-08 13:55 11471。尽量不要使用 like '%..%' 2 ... -
Oracle执行计划详解
2011-07-26 11:40 1023Oracle执行计划详解 --- 作者:TTT BLOG 本文 ... -
闲谈Oracle执行计划的步骤顺序
2011-07-13 17:45 1227经过长时间学习Oracle, ... -
lspm_project_end
2011-07-01 17:13 803事务管理概述 “事务”是一个逻辑工作单元,它包括一系列的操作 ... -
oracle表分区详解
2010-12-01 12:17 970此文从以下几个方面来整理关于分区表的概念及操作: ... -
回滚段探究
2010-10-26 17:09 857http://blog.csdn.net/biti_rainy ... -
block的一些概念
2010-10-26 10:10 1103http://space.itpub.net/12361284 ... -
Oracle Buffer Cache原理总结(一)
2010-10-26 09:53 1445http://space.itpub.net/?uid-123 ... -
oracle的表空间、分区表、以及索引的总结
2010-05-18 15:32 1240表空间: Oracle的UNDOTBS01.DBF文件太大的 ... -
数据库中事务机制的进阶使用(整理)
2009-11-02 10:13 1606在前面的两篇blog中,我写了些关于数据库中的锁方面的一些内 ... -
PL/SQL Developer使用技巧
2009-08-31 13:24 8521、PL/SQL Developer记住登 ... -
oracle中的角色
2009-08-31 13:23 968一、何为角色? 我 ... -
oracle的异常处理
2009-08-18 11:07 912oracle提供了预定义例外、非预定义例外和自定义例外三 ... -
在Oracle中使用自治事务保存日志表条目
2009-08-18 10:41 1113[size=x-large] [摘要] ... -
Oracle内存参数调优技术详解
2009-07-31 16:46 1625[size=large] 前言 近来公司技术,研发都在 ... -
如何在WebLogic 8.1.6环境中查找有连接池泄漏的代码
2009-07-31 13:09 2661[size=large] 解决连接池泄漏步骤 登录we ... -
Oracle导出程序Exp的使用
2009-07-16 12:23 2702http://www.blogjava.net/xiaohu/ ... -
createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,Re
2008-11-25 17:14 1053用缺省设置创建时,ResultSet 是一种只能访问一次(on ... -
oracle 闪回查询
2008-11-21 14:22 1388--对一般用户如果想执行 闪回查询 需要设置下列3个参数! 1 ...
相关推荐
执行计划比较复杂的SQL语句质量就不是很高 我们还可以结合时间统计【set statistics TIME ON..】一起使用,通过和时间统计结合使用可以更好地发挥执行计划的作用 有了执行计划和执行时间我们就很容易判断一条...
运行速度约有22.75倍的提升(源SQL语句运行时间为2.73秒,SQL124运行时间为0.12秒,如图5)。图5 测试结果 我们把SQL124放入源代码中,结束一条SQL语句的优化工作。从上例可以看到,LECCO SQL Expert的自动重写技术使...
SQL语法大全 SQL语法大全 1. ASP与Access数据库连接: dim conn,mdbfile mdbfile=server.mappath("数据库名称.mdb") set conn=server.createobject("adodb.connection") conn.open "driver={microsoft access ...
0865 提高SQL性能加快执行速度 513 0866 控制批处理内语句的执行 513 0867 执行查询但是显示列信息 514 0868 获取连接或试图连接的次数 514 0869 获取当前数据库的语言名 514 19.5 时间与谓词 514 0870...
SQL(Structured Query Language)结构化查询语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统。同时也是数据库脚本文件的扩展名。 SQL语言主要包含5个部分 数据定义...
2.2.2.1 从一普通查询SQL说起20 2.2.2.2 老余故事终现用心良苦23 2.2.2.3 一起体会Oracle代价 27 2.2.3 体系结构原理再探 30 2.2.3.1 从一普通更新语句说起30 2.2.3.2 体系结构中提交的探讨34 2.2.3.3 劳模的评选 38...
10.2.4 在子窗体中使用SQL的UNION语句查询所有记录 266 10.2.5 在组合框控件外显示组合框的列 268 10.2.6 根据用户的输入添加新的组合框选项 271 10.3 使用本机的Access选项卡控件 273 10.3.1 本机的选项卡...
10.2.4 在子窗体中使用SQL的UNION语句查询所有记录 266 10.2.5 在组合框控件外显示组合框的列 268 10.2.6 根据用户的输入添加新的组合框选项 271 10.3 使用本机的Access选项卡控件 273 10.3.1 本机的选项卡控件...
§14.8.1 嵌套连接- 181 §14.8.2 合并连接- 183 第15章 使用优化器提示 183 §15.1 提示(Hint)概念 184 §15.1.1 提示的指定 184 §15.2 使用提示 185 §15.2.1 提示的指定 185 §15.2.1.1 ALL_ROWS 186 §15.2....
85 <br>0130 复制字符串中指定的字符 85 <br>0131 巧截字符串的数字 86 <br>0132 如何存储变长字符串 86 <br>0133 在进行字符串比较时忽略大小写 87 <br>0134 如何去除字符串尾空格 87 ...
phpDesigner 设计最主要的目的就是加快你的编程速度,让你更轻松。然而,也正是这个原因,它更倾向于初学者。 优秀代码编辑器工具 PhpDesigner 中文版优秀代码编辑器工具 PhpDesigner 中文版 phpDesigner 最主要的...
重点掌握查询语句的使用,包括连接查询和嵌套查询。 (3)了解嵌入式SQL和动态SQL技术。 2.重点、难点 重点:掌握SQL语言的各种用法 (四)关系数据理论 ( 2学时) 1 问题的提出 2 规范化(1~4NF) 3 数据依赖的公理...
数据工程课堂笔记 第1讲 我们创建了我们的个人笔记存储库并更新了这个自述文件。 大数据有哪些组成部分? 社交网络 数据分析 贮存 无SQL Infoviz - 您如何向用户显示大数据集?...API 版本控制 资源嵌套 Ruby 客户端
7.2.3. SELECT查询的速度 7.2.4. MySQL怎样优化WHERE子句 7.2.5. 范围优化 7.2.6. 索引合并优化 7.2.7. MySQL如何优化IS NULL 7.2.8. MySQL如何优化DISTINCT 7.2.9. MySQL如何优化LEFT JOIN和RIGHT JOIN 7.2.10. ...