Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Profiler trace - duration millisecond/microsecond?

Author  Topic 

cas_o
Posting Yak Master

154 Posts

Posted - 2009-10-30 : 08:00:16
I have a large trace file taken during a consulting session with a potential customer experiencing performance issues with their system. It's a Sql Server 2005 Enterprise Edition instance. My theory is contention is their biggest problem. I want to present this as part of a report by showing lock stats and that cpu is a particularly small percent of duration in a lot of transactions indicating big wait times.

I saved the trace file as a table. Some bright spark (bonus points for anyone who can supply the reason for this) Decided that for Sql Server 2005 onwards event duration would now be reported in microseconds, but CPU remains in milliseconds. BUT just in case that's not confusing enough the Profiler GUI shows this converted to milliseconds but once you put it in a table it's raw microseconds.

[url=http://msdn.microsoft.com/en-us/library/ms175848.aspx]msdn online[/url] suggests in an example "... where CPU < (Duration * 1000) ..."

Either I am mad or very stupid shouldn't that be: "... where CPU < (Duration / 1000) ..." ???

Anyway the long and short of it is I don't know what I'm looking at and wondered if anyone else had worked this out already. Also I know that the customers database is running in 2k compatibility mode !! so I have no idea if that effects these trace events (prior to Sql Server 2005 duration was in milliseconds) Does anyone know?

For bonus tickles I am not alone read the comment at the end of the msdn article :)

Finally some interesting trivia: there is a batch complete event in the trace with a duration so long it overflowed bigint when being saved to the table, ending up as -6050 microseconds (or maybe it's milliseconds who knows) therefore I would never have seen it in my analysis but for blind luck during a random scroll (what are the chances my trace is just short of 1 million rows )


EDIT: I just realised I have this in the 2008 forum. Doh! sorry. sure some mod will clear it up... hopefully.
cas_o AKA: Holly Styles, Paul Alcon ;-]... Quack Waddle

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-30 : 11:45:33
In 2005, the duration is stored in microseconds. However the GUI SQL Profiler displays it in milliseconds. When you query the table or the file, it is in microseconds. I use this to convert it to seconds: Duration/1000000.0 AS DurationInSecs

Here's my blog that discusses this microsecond/millisecond thing: http://weblogs.sqlteam.com/tarad/archive/2006/10/04/13621.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

cas_o
Posting Yak Master

154 Posts

Posted - 2009-10-30 : 13:26:37
Thanks tkizer I did find your blog before.

What's still unclear is what the deal is when the database is in Sql 2k Compatability mode?

I am sure it must be milliseconds. Because otherwise all my batches have durations much much smaller than the CPU time (I am looking at the trace saved to a table not the GUI)

cas_o AKA: Holly Styles, Paul Alcon ;-]... Quack Waddle
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-30 : 14:50:44
mine shows microseconds regardless of compatibility mode
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-10-30 : 15:10:34
The compatibility level is not relevant to the trace data.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -