I've just recently started using LINQ on a daily basis. I've read quite a lot about L2E queries should be compiled to improve performance using the following:
CompiledQuery.Compile(query);
Using LINQ-To-Entities 4.0 I ran a query 10 times uncompiled and then compiled and yielded the following results in seconds:
// Sample Query
from u in ctx.Users orderby u.Id, u.Username select u
Uncompiled Compiled
---------------------
0.295 0.2946174
0.024 0.0220462
0.008 0.0060126
0.013 0.0210441
0.007 0.010021
0.011 0.010021
0.008 0.0060126
0.009 0.0070147
0.008 0.0060126
As you can see there's not a real big difference in the times from my small test. There is slower time for the first call, and then both speed up (implying compilation/caching). Can anyone provide insight to this?