views:

1413

answers:

3

I'm running a data import (using C#/Linq), and naturally I'm trying to optimize my queries as much as possible. To this end I'm running a trace on the DB using SQL Server Profiler, with my trace filtered by my SQL login name (it's a name that can uniquely be attributed to my data import process).

Strangely enough, most of my SQL statements are really quick :) - very few queries even break over the 1ms mark. But spaced in between all my queries are several rows where the EventClass is "Audit Login" or "Audit Logout" - and the duration of an "Audit Logout" can be up to a minute!

Has this got something to do with the fact that I'm using transactions in my import? If so, is there any way to find which are the big-hitting queries so I can clean those up?

+3  A: 

If I remember correct, the duration of an Audit Logout is the amount of time the connection was open. E.g. nothing to do with speed of the command - just the amount of time the login was 'logged in'.

Thies
Interesting, thanks! But then why is the number of reads so high (~400,000) when the number of reads for the queries between the "login" and "logout" is only 56?
Shaul
It is the number of ms from login to logout. Not the actual amount of times the queries within the connection used. 400 000ms is about 7 minutes. Look at the CPU, reads and write columns to try and locate queries that are high on CPU and/or disk usage - both killing performance.
Thies
+2  A: 

Login/Logout events are related to the setting up / tearing down. IIRC the time is the 'was logged in for time' as opposed to a processing duration as with other log events.

In general, one hides these events unless you suspect there's an issue with connection pool management etc.

The raw times for the batches should be sufficient to diagnose the time the actual activity is taking including the impact of any transactions etc.

Ruben Bartelink
A: 

hi i am having a problem.. my sqlserver.exe CPU utilization showing more than 95% .. it is in between 90-97%. I have checked the profiler.. seen Audit Login and Audit logout events.. the Reads and Durations are high.. more that 4 sec. but the CPU is showing 0

Then how the CPU utilization more than 90%

bobo sinha
Ask your own question - nobody is going to answer you here. I recommend you delete this "answer", too.
Shaul