如何用合并联接替换哈希匹配? [英] How to replace Hash Match with Merged Join?

查看:41
本文介绍了如何用合并联接替换哈希匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习SQL Server联接操作的工作方式,并且正在使用Adventure Works 2017 db.

I'm learning how SQL Server join operations works and I'm working on Adventure Works 2017 db.

这是我的查询:

SELECT 
   e.JobTitle, a.City,
   p.LastName + ', ' + p.FirstName AS EmployeeName
FROM HumanResources.Employee AS e
INNER JOIN Person.BusinessEntityAddress AS bea
   ON e.BusinessEntityID = bea.BusinessEntityID
INNER JOIN Person.Address AS a
   ON bea.AddressID = a.AddressID
INNER JOIN Person.Person AS p
   ON e.BusinessEntityID = p.BusinessEntityID

执行计划:

我的问题是我该怎么办才能用合并联接替换哈希匹配操作?

My question is what can I do to replace Hash Match operation with Merged Join?

推荐答案

您可以指定请记住,在SQL Server中,提示被认为是不得已的措施.最好查看索引碎片级别,然后在查询中添加提示.

Keep in mind that, in SQL Server, hints are considered measures of a last resort. It's much better to look at missing indices and / or index fragmentation levels before nailing a hint into a query.

这篇关于如何用合并联接替换哈希匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆