因为现在用NHibernate做开发,用面向对像的方法生由NHibernate来生成SQL语句
这样对我开发项目有很大的方便,但生成的SQL语句有时候不是很理想
以下是一个对比
如:有表
Mem_member 会员表
Mem_PointHistory 会员积分表
然后我要查询出:会员积分>400且会员积分历史有记录为200的会员
以下手写
select mem_member.* from mem_member where point > 400 and exists (select 1 from mem_pointhistory where mem_pointhistory.memberguid = mem_member.guid and mem_pointhistory.point = 200)
以下NHibernate生成
SELECT this_.Guid as Guid0_0_, this_.Version as Version0_0_, this_.IsDelete as IsDelete0_0_, this_.Status as Status0_0_, this_.Name as Name0_0_, this_.MemberLV as MemberLV0_0_, this_.Point as Point0_0_, this_.CreateTime as CreateTime0_0_ FROM Mem_Member this_ WHERE (this_.Point > 400 and this_.Guid in (SELECT this_0_.Guid as y0_ FROM Mem_Member this_0_ inner join Mem_PointHistory li1_ on this_0_.Guid=li1_.MemberGuid WHERE exists(select 1 from Mem_PointHistory where this_0_.Guid=MemberGuid) and li1_.Point = 200))我想问一下,两条SQL的性能相差有多少谢谢