views:

46

answers:

2

We are starting to have numerous linq to sql queries in our code. We have started to pay more attention to performance and are starting to see queries that we think are coming from linq. They have the t1, t2...tN values, so we are sure they are linq generated. However, we are having difficulty determining the location in code that is the source of the query. Obviously we have a general idea based on the tables and columns requested.

Is there a way to "tag" or "name" a query so that is shows up in a trace to more easily identify the query?

+1  A: 

You might find my Linq-to-SQL query profiler useful; it allows you to log queries together with stack trace and db-side I/O, timings, execution plans, and other details that can be used to pinpoint both what effect the query had and where it came from (in code, what user action(s) and or calls triggered it etc).

It has a number of filter options that you can control from within your own code, so you can set it up to catch queries that fulfill specific criteria only. E.g. queries that: are expensive I/O-wise, has long execution time, does table scans, hits specific tables, even your own custom filters, etc. It is designed for runtime profiling, so you can distribute the logging component with your apps and switch it on as necessary in prod environments.

I have posted a short intro to it here: http://huagati.blogspot.com/2009/06/profiling-linq-to-sql-applications.html

And you can download the profiler and get a free 45-day trial license from: http://www.huagati.com/L2SProfiler/

KristoferA - Huagati.com
A: 

I have, to date, found no way to do this.

Jeremy Roberts