views:

76

answers:

3

Hello I am creating a windows application that will be installed in 10 computers that will access the same database thru Entity Framework.

I was wondering what's better:

  1. Spread the queries into packets (i.e. load contact then attach the included navigation properties - [DataContext.Contacts.Include("Phone"]).
  2. Load everything in one query rather then splitting it out in individual queries.
  3. You name it.

BTW I have a query that its trace string produced over 500 lines of sql, im doubting, maybe i should waive user-exprience for performance since performance is also a part of u.e.

+1  A: 

You could put your SQL in stored procedures and write your Entity Framework logic to use the procedures instead of generating the SQL and sending it over the wire.

StarShip3000
Good idea. but afterwords, should I avoid big queries or better 1 big query than 20 separate connections?
Shimmy
One big query is fine and in many cases probably what you want generally speaking. However if you do use stored procedures it will give you the option of having a parent proc with 0 or many child procedures that will let you organize or break apart your big query into smaller chunks of logic if that makes sense to do. So your .net logic will call the parent proc, but the parent may call 0 or many child procs to give you the data you need.
StarShip3000
+2  A: 

As with everything database related, it depends. Things like the connection type (LAN vs WAN), how you handle caching, database load level, type of database load (writes vs reads) etc, can all make a difference.

But in general, whenever you can reduce the number of round trips to the database that's a good thing. And remember: you can have more than one result set after executing a single SqlCommand.

Joel Coehoorn
It's going to be installed in a 10g LAN network both the clients and the server.
Shimmy
+1  A: 

Load everything in one query rather then splitting it out in individual queries.

This will normally be superior. You're usually better off writing chunkier queries than chatty ones. Fewer calls have less overhead - you need to obtain fewer connections, deal with less latency, etc..

Does the database server have to support other applications? For most business software applications, SQL server won't even break a sweat servicing ten clients - particularly performing basic entity lookups. It won't even really know you're there unless it's installed on a 486SX.

Jeff Sternal