JD Conley wrote an interesting article showing the benefits you can get by using compiled queries on his blog.  He wrote me today saying:

"I enjoyed your postings on linq to sql performance and compiled query optimization. I recently published a blog about a real world situation that benefited from a compiled query. However, it got me thinking. Are compiled queries thread safe? Can I really create a static instance of a query and use it from multiple threads simultaneously (like in an ASP.NET application)?


My gut tells me no, but all the examples I've seen assume that they are in fact thread safe. Any ideas?"

A: Absolutely you can use it like that.  That's like the main scenario it was designed for :)

And by the way JD, nice job on your analysis -- textbook approach: cast a broad net, find the key resource, drill down. Don't make too many assumptions before you look at data and don't get detailed data until you know what to look at. 

^5