Skip to content

Change nvarchar (4000) parameter for hierarchyid #6

Description

@AbbTek

As the parameters are passed as nvarchar, an SQL query is generated like this:

image

Now the query can not use the optimal index because the parameter defined as nvarchar

If you change a parameter by hierarchyid get the following:

image

On a table of 87,371 records in the first query takes 1620 ms and the second query takes 17 ms (whereas a cluster index for hierarchyid field).

For my use, just change the class IsDescendantOfExpression.

image

And create the class

image

Thanks for your work helped me a lot, I hope I help my recommendation.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions