Is there a way to prevent logical performance issues with the NHibernate LINQ provider

We used NHibernate 2.1 and I upgraded our system to 3.0 to test the new LINQ provider. I compared the linq provider, createquery and query.

Createquery and queryover did almost the same thing, the same performance. However, the LINQ provider has done some REALLY funky things!

var items = (from m in NHibernateSession.Current.Query<Listing>() where m.Active == true select m).Take(10).ToList(); var items2 = NHibernateSession.Current.CreateQuery("from Listing where Active = :val").SetBoolean("val", true).SetMaxResults(10).List(); var items3 = NHibernateSession.Current.QueryOver<Listing>() .Where(m => m.Active == true) .Take(10).List(); 

Sql from createquery and queryover:

 select TOP ( 10 /* @p0 */ ) listing0_.PackageID as PackageID13_, listing0_.MatchComplete as MatchCom2_13_, listing0_.ExpirationDate as Expirati3_13_, listing0_.Active as Active13_, listing0_.Archived as Archived13_, listing0_.Deleted as Deleted13_, listing0_.UserID as UserID13_ from Marketplace.Listings listing0_ where listing0_.Active = 1 /* @p1 */ 

Request from LINQ:

 select TOP ( 10 /* @p0 */ ) listing0_.PackageID as PackageID13_, listing0_.MatchComplete as MatchCom2_13_, listing0_.ExpirationDate as Expirati3_13_, listing0_.Active as Active13_, listing0_.Archived as Archived13_, listing0_.Deleted as Deleted13_, listing0_.UserID as UserID13_ from Marketplace.Listings listing0_ where case when listing0_.Active = 1 then 'true' else 'false' end = case when 'True' /* @p1 */ = 'true' then 'true' else 'false' end 

NH Profiler's duration for LINQ is 37/91 compared to 2/2

Is this supposed to be happening? Or am I missing a configuration setting to specify LINQ to convert logical comparisons to bits?

thanks

+4
source share
1 answer

Found a solution in 3.2. This was reported as a bug and fixed for the next version.

+1
source

All Articles