[步骤]
(@CustomerID0 int,@IsGroup1 int,@ProductState2 int,@ProductProperty3 int,@CheckStatus4 int,@DevelopStatus5 int,@DevelopStatus6 int,@IsDelete8 bit)SELECT COUNT(1) FROM [RB_Product] [b] WITH(NOLOCK) Inner JOIN [RB_Product_Admin] [c] WITH(NOLOCK) ON (( [b].[CustomerID] = [c].[CustomerID] ) AND ( [b].[SKU] = [c].[SKU] )) WHERE ((((( [b].[CustomerID] = @CustomerID0 ) AND ( [b].[IsGroup] <> @IsGroup1 )) AND ( [b].[ProductState] <> @ProductState2 )) AND ( [b].[ProductProperty] <> @ProductProperty3 )) AND ((( [c].[CheckStatus] = @CheckStatus4 ) OR ( [c].[DevelopStatus] = @DevelopStatus5 )) OR ( [c].[DevelopStatus] = @DevelopStatus6 ))) AND ([c].[AddAdminID] IN (563)) AND (NOT EXISTS ( SELECT * FROM [E_Product_Amazon_BrowseTree] WHERE ((( [SKU] = [b].[SKU] ) AND ( [IsDelete] = @IsDelete8 )) AND ( [IsMain]=1 ) ) ))
SELECT Count(1)
FROM [RB_Product] [b] WITH(NOLOCK)
INNER JOIN [RB_Product_Admin] [c] WITH(NOLOCK)
ON ( ( [b].[CustomerID] = [c].[CustomerID] )
AND ( [b].[SKU] = [c].[SKU] ) )
WHERE ( ( ( ( ( [b].[CustomerID] = @CustomerID0 )
AND ( [b].[IsGroup] <> @IsGroup1 ) )
AND ( [b].[ProductState] <> @ProductState2 ) )
AND ( [b].[ProductProperty] <> @ProductProperty3 ) )
AND ( ( ( [c].[CheckStatus] = @CheckStatus4 )
OR ( [c].[DevelopStatus] = @DevelopStatus5 ) )
OR ( [c].[DevelopStatus] = @DevelopStatus6 ) ) )
AND ( [c].[AddAdminID] IN ( 563 ) )
AND ( NOT EXISTS (SELECT *
FROM [E_Product_Amazon_BrowseTree]
WHERE ( ( ( [SKU] = [b].[SKU] )
AND ( [IsDelete] = @IsDelete8 ) )
AND ( [IsMain] = 1 ) )) )

[结果]
[期望]
应该 包含条件 [CustomerID] = @CustomerID0 这样才能走索引
AND ( NOT EXISTS (SELECT *FROM [E_Product_Amazon_BrowseTree]
WHERE ( ( ( [SKU] = [b].[SKU] )
AND ( [IsDelete] = @IsDelete8 ) )
AND ( [IsMain] = 1 ) )) and [CustomerID] = @CustomerID0 )
