我们正在为客户开发一个新系统,我们有一个拥有约23600名成员的成员表。当我们试图让它们全部耗尽时。我已经使用sql profiler来获取问题并分别运行它,大约需要3秒钟。
using (ISession s = SessionFactory.OpenSession())
{
return CreateCriteria(typeof(Member)).List<Member>();
}
看起来问题是23600对象的结果映射花费的时间太长。 当将结果限制为示例300(.SetMaxResults(300))时,它工作正常。我现在不知道如果我们真的需要在最终系统中真正获得所有成员,但我知道到时候我们希望让大多数成员在我们网站的会员提供商中生成他们的帐户。
成员映射(流利的nHibernate):
Id(x => x.ID).Default("NEWID()");
Map(x => x.LegacyID).ReadOnly();
Map(x => x.Username).Length(32);
Map(x => x.Password).Length(32);
Map(x => x.MemberID).Length(10);
Map(x => x.FirstName).Length(50);
Map(x => x.LastName).Length(50);
Map(x => x.Gender).CustomType<int>();
Map(x => x.BirthDate);
Component(c => c.Home);
Map(x => x.Email).Length(80);
Map(x => x.SendInformation).CustomType<int>();
Map(x => x.SendInvoice).CustomType<int>();
Map(x => x.Comment);
Map(x => x.PublicProfile);
Map(x => x.EntryDate);
Map(x => x.ResignationDate);
References<ProfileItem>(x => x.MemberStatus, "StatusID");
References<ProfileItem>(x => x.MemberType, "TypeID");
References<ProfileItem>(x => x.NationalAssociation);
References<ProfileItem>(x => x.Position, "PositionID");
References<ProfileItem>(x => x.SpecialSkills, "SpecialSkillsID");
References<ProfileItem>(x => x.CompanyType, "CompanyTypeID");
References<ProfileItem>(x => x.JobType, "JobTypeID");
References<ProfileItem>(x => x.GraduateCity, "GraduateCityID");
HasManyToMany<ProfileItem>(x => x.Interessts).Table("MemberInterests")
.ParentKeyColumn("UserID").ChildKeyColumn("ProfileItemID").Cascade.AllDeleteOrphan().Not.LazyLoad();
HasManyToMany<ProfileItem>(x => x.Properties).Table("MemberProperties")
.ParentKeyColumn("UserID").ChildKeyColumn("ProfileItemID").Cascade.AllDeleteOrphan().Not.LazyLoad();
Component(c => c.Company).ColumnPrefix("Work");
Component(c => c.Invoice).ColumnPrefix("Invoice");
Map(x => x.Created);
Map(x => x.CreatedBy).Length(32);
Map(x => x.LatestChange);
Map(x => x.LatestChangeBy).Length(32);
Map(x => x.ElementarySchool);
Map(x => x.University);
Map(x => x.GraduateYear);
Map(x => x.Title).Length(50);
Map(x => x.LibraryAccess);
任何人都知道这个问题或如何修复它?
答案 0 :(得分:1)
获取如此大的数据集并不是一个好主意。想想内存消耗。如果您需要处理此数据,请考虑以批次(最多1000个项目)进行处理。如果您需要向用户提供现有数据,请考虑分页。如果无法减少获取的数据集,可以增加超时,但不推荐练习。