When writing manual SQL its pretty easy to estimate the size and shape of data returned by a query. I’m increasingly finding it hard to do this with LINQ to SQL queries. Sometimes I find WAY more data than I was expecting – which can really slow down a remote client that is accessing a database directly.
I’d like to be able to run a query and then tell exactly how much data has been returned across the wire, and use this to help me optimize.
I have already hooked up a log using the DataContext.Log method, but that only gives me an indication of the SQL sent, not the data received.
Any tips?
Looks like you can grab the SqlConnection of your DataContext and turn on statistics.
One of the statistics is ‘bytes returned’.
MSDN Reference Link