Is there a way to prevent boolean performance problems with NHibernate LINQ provider
We were using NHibernate 2.1 and I upgraded our system to 3.0 to test the new LINQ provider. I compared the linq provider, createquery, and queryover.
Createquery and queryover did pretty much the same thing, same perfo开发者_JS百科rmance. However the LINQ provider did some REALLY funky stuff!
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 & 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 */
Query 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
The duration from NH Profiler for LINQ is 37/91 compared to 2/2
Is this supposed to be happening? Or am I missing a configuration setting for telling LINQ to convert Boolean comparisons to bit?
Thanks
Found the solution is in 3.2. This was reported as a bug and fixed for the next version.
精彩评论