为什么NHibernate PrepareQuery花了这么多时间?

时间:2011-12-18 15:49:11

标签: performance nhibernate

我正在使用NHibernate Session.Query()方法从sql db中获取一些数据。最近我注意到查询超过1000毫秒!我发现这次使用的探查器主要用于NHibernate.Linq.DefaultQueryProvider.PrepareQuery()(70%),实际查询只花费300ms。查询看起来像这样

var q = session.Query<Answer>().
        Where(a => a.User.IsExpert);

结果sql是这样的:

select answer0_.ID          as ID0_,
   answer0_.TotalAnswer as TotalAns2_0_,
   answer0_.Rating0     as Rating3_0_,
   answer0_.Rating1     as Rating4_0_,
   answer0_.Rating2     as Rating5_0_,
   answer0_.Rating3     as Rating6_0_,
   answer0_.caseID      as caseID0_,
   answer0_.userid      as userid0_
from   Answer answer0_
   inner join Users user1_
     on answer0_.userid = user1_.ID
where  user1_.IsExpert = 1

如何加速PrepareQuery调用?

0 个答案:

没有答案