[步骤]
zhcxkj-erpapi-dotnet-api-6b58b7797f-x9h79 项目中 发现请求 读库 SQL语句查询 产生了 死锁
该语句如下
(@CustomerID1 int)
SELECT [l].[Id] AS [ID] , [l].[SKU] AS [SKU] , [l].[OrderCode] AS [OrderCode] , [l].[ProductType] AS [ProductType] ,
[l].[ProductPrice] AS [ProductPrice] , [l].[BuyPrice] AS [BuyPrice] , [l].[ShippingPrice] AS [ShippingPrice] , [l].[AddTime] AS [AddTime] ,
[i].[TransportID] AS [TransportID] , [i].[Country] AS [Country]
FROM [RB_OrderInfo] [i] WITH(NOLOCK)
Inner JOIN [RB_OrderList] [l] WITH(NOLOCK) ON (( [i].[CustomerID] = [l].[CustomerID] ) AND ( [i].[OrderCode] = [l].[OrderCode] ))
Left JOIN [RB_Transport] [t] WITH(NOLOCK) ON (( [i].[TransportID] = [t].[Id] ) AND ( [i].[CustomerID] = [t].[CustomerID] ))
WHERE (([l].[Id] IN ('215651925')) AND( [l].[CustomerID] = @CustomerID1 ))
([l].[Id] IN ('215651925')) in 的时候 添加了 引号 RB_OrderList 的ID 字段 为 int 类型,当统计信息 更新不及时 容易产生参数嗅探,导致类型转换
[结果]
[期望]
建议 ([l].[Id] IN ('215651925')) 去掉 IN 中 数值的引号
