什么是伪合并连接?

What is a pseudo-merge join?

这是 Microsoft TechNet 解释跟踪标志 342 的描述(强调已添加):

Disables the costing of pseudo-merge joins, thus significantly reducing time spent on the parse for certain types of large, multi-table joins. One can also use SET FORCEPLAN ON to disable the costing of pseudo-merge joins because the query is forced to use the order specified in the FROM clause.

你们知道什么是伪合并连接吗?据我所知,SQL 服务器有 3 种连接算法(Nest Loop Join、Merge Join 和 Hash Join - 其中包括 Bitmap Join)。那么什么是伪合并联接,它与常规合并联接或任何其他联接之间有什么区别?

我知道这是一个老问题,但我会尽可能具体地回答它。

Pseudo-merge 不是用作 T-SQL 语言运算符的 Join 类型,我对 Microsoft explanation 的解释是使用 Trace Flag 342 如下:

Disables the costing of pseudo-merge joins, thus significantly reducing time spent on the parse for certain types of large, multi-table joins.

伪合并是一个概念,表示查询优化器试图计算出一个更好的查询执行计划,试图获得将几个表连接起来的最佳方式。

One can also use SET FORCEPLAN ON to disable the costing of pseudo-merge joins because the query is forced to use the order specified in the FROM clause.

此选项 prevents the optimizer from trying to calculate 并简单地执行查询中列出的连接。

一篇关于SET FORCEPLAN ON的文章供参考。