SQL Server 执行连接的方式 - Merge Join
2013-06-25 13:09
260 查看
The merge join requires both inputs to be sorted on the merge columns, which are defined by the equality (ON) clauses of the join predicate. The query optimizer typically scans an index, if one exists on the proper set of columns,
or it places a sort operator below the merge join. In rare cases, there may be multiple equality clauses, but the merge columns are taken from only some of the available equality clauses.
Because each input is sorted, the Merge Join operator gets a row from each input and compares them. For example, for inner join operations, the rows are returned if they are equal. If they are not equal, the
lower-value row is discarded and another row is obtained from that input. This process repeats until all rows have been processed.
The merge join operation may be either a regular or a many-to-many operation. A many-to-many merge join uses a temporary table to store rows. If there are duplicate values from each input, one of the inputs will have to rewind
to the start of the duplicates as each duplicate from the other input is processed.
If a residual predicate is present, all rows that satisfy the merge predicate evaluate the residual predicate, and only those rows that satisfy it are returned.
Merge join itself is very fast, but it can be an expensive choice if sort operations are required. However, if the data volume is large and the desired data can be obtained presorted from existing B-tree indexes, merge join is
often the fastest available join algorithm.
http://technet.microsoft.com/en-us/library/ms190967(v=sql.105).aspx
or it places a sort operator below the merge join. In rare cases, there may be multiple equality clauses, but the merge columns are taken from only some of the available equality clauses.
Because each input is sorted, the Merge Join operator gets a row from each input and compares them. For example, for inner join operations, the rows are returned if they are equal. If they are not equal, the
lower-value row is discarded and another row is obtained from that input. This process repeats until all rows have been processed.
The merge join operation may be either a regular or a many-to-many operation. A many-to-many merge join uses a temporary table to store rows. If there are duplicate values from each input, one of the inputs will have to rewind
to the start of the duplicates as each duplicate from the other input is processed.
If a residual predicate is present, all rows that satisfy the merge predicate evaluate the residual predicate, and only those rows that satisfy it are returned.
Merge join itself is very fast, but it can be an expensive choice if sort operations are required. However, if the data volume is large and the desired data can be obtained presorted from existing B-tree indexes, merge join is
often the fastest available join algorithm.
http://technet.microsoft.com/en-us/library/ms190967(v=sql.105).aspx
相关文章推荐
- SQL Server 执行连接的方式 - Nested Loops Joins
- SQL Server 执行连接的方式 - Hash Join
- sql server 数据库连接方式分析、详解
- IIS7下的Web应用程序以“Windows集成安全性”方式连接到远程SQL Server
- Sql server定时执行某个sql 通过Windows 计划任务(非代理Job方式)
- com.microsoft.sqlserver.jdbc.SQLServerDriver直连方式连接Sql server 2008
- SQL server 内部实三种类型的物理连接运算:Merge join、Hash join、Nested loop join对比分析
- 学习如何看懂SQL Server执行计划(三)——连接查询篇
- SQL Server 2005 无法连接到WMI提供程序 无法执行 SQL Server 系统配置检查器
- Unix/Linux中后台运行程序(断开shell连接后继续执行)的几种方式
- 在非SQL客户端使用命令行方式定期连接SQL Server 服务器并模拟用户查询操作,同时输出信息内容
- ADO连接SQL SERVER的两种方式
- VS2010连接SQL Server 2008并执行查询操作
- 分享一下SQL Server执行动态SQL的正确方式
- 查看sql执行计划时的表连接方式
- python连接sql server并执行查询操作
- Sql Server 优化----SQL语句的执行方式与锁以及阻塞的关系
- Sql Server远程连接数据库(相当于Oracle的dblink方式)
- SQL Server 查询分析器的执行计划中的扫描方式,举例理解
- sql server 中的几种join连接方式