我们正在为一个客户开发一个新系统,我们有一个包含大约 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);
任何人都知道这个问题或如何解决它?