RaveNoX / NHibernate.HierarchyId

Adds support for MS SQL HierarchyId type to NHibernate 3
MIT License
6 stars 9 forks source link

Change nvarchar (4000) parameter for hierarchyid #6

Open AbbTek opened 10 years ago

AbbTek commented 10 years ago

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.