2

In this question Is it parameter sniffing? there is an execution plan attached with the XML.

Why is ParameterCompiledValue missing from the XML of the execution plan?

       <ParameterList>
          <ColumnReference Column="@__trailerLocation_SbtAssetid_12" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9511'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_11" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'8184'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_10" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9628'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_9" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9683'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_8" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9234'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_7" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9204'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_6" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9628'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_5" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'9852'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_4" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'5842'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_3" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'4138'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_2" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'7505'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_1" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'7826'" />
          <ColumnReference Column="@__trailerLocation_SbtAssetid_0" ParameterDataType="nvarchar(12)" ParameterRuntimeValue="N'8604'" />
        </ParameterList>

I expect both ParameterCompiledValue and ParameterRuntimeValue in the XML like this example.

        <ParameterList>
          <ColumnReference Column="@contactPersonID" ParameterDataType="int" ParameterCompiledValue="(1025)" ParameterRuntimeValue="(1025)" />
        </ParameterList>

1 Answer 1

3
+50

You can disable the parameter sniffing. When there is no sniffing, there is no compiled value (since it wouldn't be used anyway)

For example on the database level with:

ALTER DATABASE SCOPED CONFIGURATION

ALTER DATABASE SCOPED CONFIGURATION SET PARAMETER_SNIFFING = OFF

Or on query level with a Query Hint

Example procedure:

CREATE OR ALTER PROCEDURE dbo.ProcWithParam
(
    @objectName sysname
)
AS
    SELECT * FROM sys.objects AS o
    WHERE o.name = @objectName
    OPTION (OPTIMIZE FOR UNKNOWN)
go
EXEC dbo.ProcWithParam @objectName = N'sysclsobjs'

```

But the query hint would most likely show up in the SQL text portion of the query plan

1
  • Yes, it does show up if it is a statement-level hint. Thank you. Commented Jun 21 at 13:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.