Blog Post

Run real-time SQL tracing at application level with a ORM….

,

If you ever need to know exactly what dml your application is running as you have an ORM as your persistence layer like NHiberate. The most effective way is to add an application name parameter to your ado connection string and use SQL Server Profiler, to listen for this application, see below:-

Change application’s ado connection string:-

“Data Source=XXXXX;Initial Catalog=XXXXXX;Integrated Security=True;Pooling=False”

To:-

“Data Source=XXXXX;Initial Catalog=XXXXXX;Integrated Security=True;Pooling=False;Application Name=GOSQL”

Go to SQL Server Profiler, start a new profile using the standard ‘SQL’ profile.

On the ‘Events Selection’ tab select ‘Show all columns’.

Select ‘Column Filters’.

Select ‘ApplicatioName’ expand ‘Like’ enter your application name, and select ‘Exclude rows that do not contain values’.

Select ‘OK’, and ‘Run’.

Any request coming through as your application name will be profiles for analyzing later.

This is a very good technique if your are trying to identify what dml the ORM is rendering under the hood. Once you have identified your the dml, you can tackle your problem with a better understanding of what the application and database are trying to do.Image

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating