sql 2005 强制使用执行计划 T—SQl
2010-04-27 14:46
447 查看
select * from tt t inner loop join ss s with(nolock) on s.c=t.c
使用 nested join
select * from tt t inner merge join ss s with(nolock) on s.c=t.c
使用 merge join
select * from tt t inner hash join ss s with(nolock) on s.c=t.c
使用 hash jion
nolock 不允许锁
Microsoft SQL Server sometimes uses hash and merge joins when querying large tables when uncomplicated nested loop joins would result in better performance and less server impact. In many such cases, query times go from many milliseconds to many seconds because hash table joins require that large amounts of data be processed and temporarily stored, and merge joins require sorting and then processing similarly large amounts of data.
This is fine for one-time administrative "fact finding" queries where you don't have or want the indices needed to optimize the query, and you're willing to wait the seconds or minutes it takes to get results.
For day-in-and-day-out application queries, however, you don't want your database engine to be hashing or sorting hundreds of thousands or millions of rows, especially when the end result is only a small number of rows.
使用 nested join
select * from tt t inner merge join ss s with(nolock) on s.c=t.c
使用 merge join
select * from tt t inner hash join ss s with(nolock) on s.c=t.c
使用 hash jion
nolock 不允许锁
Microsoft SQL Server sometimes uses hash and merge joins when querying large tables when uncomplicated nested loop joins would result in better performance and less server impact. In many such cases, query times go from many milliseconds to many seconds because hash table joins require that large amounts of data be processed and temporarily stored, and merge joins require sorting and then processing similarly large amounts of data.
This is fine for one-time administrative "fact finding" queries where you don't have or want the indices needed to optimize the query, and you're willing to wait the seconds or minutes it takes to get results.
For day-in-and-day-out application queries, however, you don't want your database engine to be hashing or sorting hundreds of thousands or millions of rows, especially when the end result is only a small number of rows.
相关文章推荐
- sqlser 2005 使用执行计划来优化你的sql
- SQL Tuning 基础概述03 - 使用sql_trace和10046事件跟踪执行计划
- MySql中如何使用 explain 查询 SQL 的执行计划
- 固定执行计划-使用coe_xfr_sql_profile
- 使用 EXPLAIN PLAN 获取SQL语句执行计划
- 使用dbms_shared_pool.purge清除共享池中的SQL执行计划
- VIsual Basic 2005 - 如何使用 SqlBulkCopy 对象来执行大量复制作业
- 使用SQL Profile及SQL Tuning Advisor固定执行计划
- 使用hint优化Oracle的执行计划 以及 SQL Tune Advisor的使用
- 强制SQL Server执行计划使用并行提升在复杂查询语句下的性能
- SQL执行计划、绑定变量的使用
- 如何使用ordered提示改变SQL执行计划
- SQL优化--使用 EXISTS 代替 IN 和 inner join来选择正确的执行计划
- 从一个SQL使用了不理想的执行计划说开,浅谈执行计划如何估算cache信息的影响及系统统计信息的收集等(2010-10-15)
- 使用 EXPLAIN PLAN 获取SQL语句执行计划
- 微软的DreamSpark计划-学生可免费使用vs2008 pro,sql server Dev 2005,Expression Studio等产品
- 查看Oracle执行计划的几种方法 / oracle中DateTime类型的字段,建立索引后,查寻时索引如何生效?/ oracle 中sql语句怎么加多个强制索引
- 使用mysql profiles 来查看sql 语句执行计划
- 使用 EXPLAIN PLAN 获取SQL语句执行计划
- 如何在SQL*PLUS中使用Autotrace?(看执行计划)