nHibernate rows insertion performance issue


#1

Let’s say we have a simple test table in our database and we use a simple Hibernate object in order to work with it. The addition of 150 entries (150 ISession.Save() calls) in a single transaction can easily take 100-200 milliseconds (in case of MySQL and in case of Postgresql database)… Is this normal, or are we missing something and we should change something in Hibernate / our database in order to improve the performance of this operation? We have tried to disable flushing and call it before the Commit(), but it hasn’t changed much…

[Class(Table = “test”)]
public class TestEntity
{
private int id;
[Id(0, Column = “id”, Name = “Id”)]
[Generator(1, Class = “native”)]
public virtual int Id { get { return id; } set { id = value; } }

[Property(Column = "test_column")]
protected virtual float testColumn { get; set; }
public virtual float TestColumn1 { get { return testColumn; } set { if (testColumn != value) { testColumn = value; MakeUpdated(); } } }

public TestEntity() { }

public TestEntity(float t)
{
  this.testColumn = t;
}

}


#2