long delay on first query with large model
Posted: Thu 03 May 2012 13:34
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
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
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());
}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