Query tuning 101: What’s a probe residual?
Query tuning 101: What’s a probe residual?
Query tuning is an important process that will probably never go away and sharpening your tuning skills is always a good idea.
I’ve spoken on this topic many times and talked about probe residuals before. Mostly at SQL Saturday events and for some online webinars.
A probe residual is important because they can indicate key performance problems that might not otherwise be brought to your attention.
What is a probe residual?
Simply put, a probe residual is an extra operation that must be performed to compete the matching process. Extra being left over things to do.
Let’s look at the following example:
SELECT P.Name,
D.OrderQty,
D.UnitPrice
FROM Production.ProductArchive2013 AS P
INNER JOIN Sales.SalesOrderDetail AS D ON (p.ProductID = D.ProductID)SELECT P.Name,
D.OrderQty,
D.UnitPrice
FROM Production.ProductArchive2014 AS P
INNER JOIN Sales.SalesOrderDetail AS D ON (p.ProductID = D.ProductID)
GO
These two queries are the same minus selecting from two different productarchive tables. Note that the top query has a slightly lower cost.
What’s different?
Without knowing about Probe Residual you’d think these plans were the same when in fact they are not.
On further investigation, the Hash Match operator reveals a residual operation:
Why is that and what is that?
In this particular case, the residual operation is due to an implicit conversion; though, this isn’t indicated anywhere in the query plan whatsoever. The implicit isn’t even found searching through the plan XML.
Reviewing the table DDL shows that the ProductID column of the ProductArchive2014 was created with BIGINT and it’s INT everywhere else.
CREATE TABLE [Production].[ProductArchive2014](
[ProductID] [bigint] NOT NULL, …CREATE TABLE [Production].[ProductArchive2013](
[ProductID] [int] NOT NULL, …CREATE TABLE [Sales].[SalesOrderDetail](
…
[ProductID] [int] NOT NULL, …
Simply put, this query could be faster by fixing the data types and the Probe Residual helps reveal this.
Note that not every Probe Residual will be caused by an implicit conversion; however, they are a noteworthy tuning item to review.
For more about query plans be sure to check out my other site: How’s My Plan (howsmyplan.com)
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2020-05-28 To Allow App through Windows Defender Firewall in Command Prompt
2019-05-28 Activator.CreateInstance with parameters
2019-05-28 outlook使用inline style回复邮件
2019-05-28 回复git@vger.kernel.org的注意事项
2019-05-28 Majordomo Info VGER.KERNEL.ORG
2018-05-28 how to modify vs2017
2018-05-28 node inspector的安装以及使用【已经淘汰了】