Hi, I am trying to insert a relatively modest amount of data via NHibernate. The data consists of about 400 objects that contain two lists of child objects (1-2 child objects per list). The way the objects are inserted into the database is relatively inefficient because it happens one object at a time. However, the insert runs for many minutes, which seems long even given this inefficiency.
How would I got about improving the performance? Can I change something in by database configuration or mappings to speed up this process?
Here is the DB configuration:
Code:
private static ISessionFactory CreateSessionFactory()
{
//Create session
return Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008 .ConnectionString(ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString).ShowSql().AdoNetBatchSize(50))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<Schedule>())
.BuildSessionFactory();
}
And here is the mapping for the object in question:
Code:
public class RotationEventMap : ClassMap<RotationEvent>
{
public RotationEventMap()
{
Id(x => x.UniqueID);
HasMany(x => x.TimeSlots).Not.LazyLoad().BatchSize(100).Cascade.All();
HasManyToMany(x => x.Tags).Table("TagRotationEvent").Not.LazyLoad().BatchSize(100);
}
}
Thank you!