-1

I have a model as follows:

 Request
    Hgx
      ICollection<Project>
          ICollection<Sample>
             ICollection<Typing>
                 ....

Quite a complex model and hierarchy. When i Save incoming request, it take 15 seconds.

How can i speed this up?

DarthVader
  • 52,984
  • 76
  • 209
  • 300
  • This is only a hunch, sorry if I just waste space under the OP. Are the properties virtual(is lazy loading enabled), maybe there is too much data retrieved from the database? – Yoda Oct 05 '14 at 18:04
  • I only do inserts. There is lot of navigation properties like that., – DarthVader Oct 05 '14 at 18:05

1 Answers1

2

EF can generate some monstruous SQL statements in more complex cases. That could be an issue in your case. But I also read this post where there exists a DataType mismatch which caused EF to execute way too slow.

EF expects nVarChars voor String Field / Columns, but if they are actually varchar in the Database this could lead to some serious performance issues. Hope you can sort things out with the help of the linked post.

Also, EF (or more in general I believe) "first queries" may take some time to initialize connection, initialize EF context and so forth. So you should really tackle a couple of areas where things get messed up. Does a direct repitition of the same insert statement executes a slsow as the first one?

Community
  • 1
  • 1
Youp Bernoulli
  • 5,303
  • 5
  • 39
  • 59