Page 1 of 1

long delay on first query with large model

Posted: Thu 03 May 2012 13:34
by gkubesch
Hello,
we have an entity model containing about 700 entities.
Unfortunately the database is already existing and has lot's of foreign key
constraints, so we can not realy shrink our model :-(

When we do a simple test like this

Code: Select all

using (Context context = new Context())
//Context does the model creation with about 700 entities 
{
  Debug.WriteLine("1 "+DateTime.Now.ToLongTimeString());
  var query = context.G_TABLE1
                     .Where(p => p.EQUI_ID == 3)
                     .ToList();
  Debug.WriteLine("2 " + DateTime.Now.ToLongTimeString());
  query = context.G_TABLE1
                     .Where(p => p.EQUI_ID == 2)
                     .ToList();
  Debug.WriteLine("3 " + DateTime.Now.ToLongTimeString());
}
the gap between output 1 and output 2 is about 5 minutes. 2 to 3 is < 1 sec!
I looked up the session in the database, but is was idle.
The cpu usage went up to 50% (from 5%) while the test was running.
Does anybody know why the first query takes so long and if there is anything we could do abaout this?

Thank you,
George

Re: long delay on first query with large model

Posted: Fri 04 May 2012 12:54
by MariiaI
Could you please specify the following:
- the version of your dotConnect for Oracle;
- the data types and approximate number of fields used in your entities;
- whether you are declaring any data load options.

If possible, please send us (http://www.devart.com/company/contact.html) the model you are working with or a sample project with which the issue can be reproduced.

Re: long delay on first query with large model

Posted: Wed 09 May 2012 08:24
by gkubesch
the version of your dotConnect for Oracle
we used version 6.60, justed upgraded to 6.80 without any performance improvement

the data types and approximate number of fields used in your entities
we have an average of 17 fields per entity (about 650 entities)
we have mostly simple datatypes (integer, number, string, long) but also blob and xmltypes

whether you are declaring any data load options
no data load options
we create out model like this

Code: Select all

Class Context ...
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
  modelBuilder.Conventions.Remove<ColumnTypeCasingConvention>();
  modelBuilder.Configurations.Add(new XXXMap());
  modelBuilder.Configurations.Add(new YYYMap());
 ...
}
our entities are created with Entity Framework Power Tools Beta 2


send us the model you are working with
as we have very strict security rules from our customer, we can not send you our model.

Re: long delay on first query with large model

Posted: Mon 14 May 2012 11:04
by Pinturiccio
You can improve the first query performance in the Entity Framework by using the Pre-generated views.

You can find detailed information about the Pre-generated views at:
http://msdn.microsoft.com/en-us/library/cc853327.aspx (Entity Framework)
http://msdn.microsoft.com/en-us/data/hh949853 (Entity Framework 5)

The are many other ways to improve the first query performance described in these articles, but we advise you to use Pre-generated views.