Slow insert

Slow insert

Postby JoeRuspante » Mon 16 Sep 2013 10:02

Hi everybody.

I have a simple model Class:

Code: Select all


    [Table("USER_TEST")]
    public class User
    {

        public long Id { get; set; }

        public string Name { get; set; }

    }



Then I have my DbContext with this settings:


Code: Select all

public class MyContext : DbContext
{

    public MyContext()
        : base("MyConnectionString")
    {
        InitializeOracle();
    }

    private void InitializeOracle()
    {
        OracleEntityProviderConfig.Instance.CodeFirstOptions.UseNonUnicodeStrings = true;
        OracleEntityProviderConfig.Instance.QueryOptions.CaseInsensitiveLike = true;
        OracleEntityProviderConfig.Instance.Workarounds.IgnoreSchemaName = true;
        OracleEntityProviderConfig.Instance.Workarounds.IgnoreDboSchemaName = true;
        OracleEntityProviderConfig.Instance.CodeFirstOptions.TruncateLongDefaultNames = false;
        OracleEntityProviderConfig.Instance.CodeFirstOptions.UseDateTimeAsDate = true;
        OracleEntityProviderConfig.Instance.Workarounds.DisableQuoting = true;
        OracleEntityProviderConfig.Instance.Workarounds.ColumnTypeCasingConventionCompatibility = true;
        }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        Database.SetInitializer<MyContext>(null);
        modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
        modelBuilder.Conventions.Remove<ColumnTypeCasingConvention>();
        modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
        base.OnModelCreating(modelBuilder);
    }

    public DbSet<User> Users { get; set; }

}





Now I try to add 1.000 users to the db:

Code: Select all

MyContext ctx = null;
try
{
   ctx = new MyContext();
   ctx.Configuration.ValidateOnSaveEnabled = false;
   for (int i = 0; i < 1000; i++)
   {
      User u = new User();
      u.Name = "User" + i.ToString();
      ctx.Users.Add(u);
   }
   ctx.SaveChanges();
}
finally
{
   if (ctx != null)
   {
      ctx.Dispose();
      GC.SuppressFinalize(ctx);
   }
}




I don't know why, but that code requires about 18 seconds to run. How can I make it faster?
If I do it by hand (OracleConnection + OracleCommand) it takes about 2.5 seconds...


I'm using:
- .Net framework 4.5
- Devart 7.4.146
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Re: Slow insert

Postby MariiaI » Mon 16 Sep 2013 13:52

We couldn't reproduce this issue in our environment. We are sending you a sample project to the e-mail address you have provided in your forum profile. Please check that the letter is not blocked by your mail filter. Please test it and notify us about the results.
If it doesn't help, please make changes to it so that the issue could be reproduced and send it back to us or send us your project.

Also, we recommend you to pay attention the OracleLoader class for such scenario.
MariiaI
Devart Team
 
Posts: 1472
Joined: Mon 13 Feb 2012 08:17


Return to dotConnect for Oracle