It all started so easy!
A customer found in one database one statement which is outstanding high in statspack reports. Unfortunately, as the application is not instrumented, it's hard to understand where the SQL is coming from and what's its purpose.
To bring it into context, a simple SQL TRACE can do miracles.
But as SQL Trace is hard to read and has a lot of confusing content, I used mrskew and a slightly modified calls.rc to generate a chronological list of all DB calls.
The result loks similar to this output
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
12568091.341788 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
12568091.343769 42 XCTEND
For everyone used to calculate seconds and miliseconds by just looking at it, and with the little additional information the tracefile starts at
*** 2020-11-26 10:06:01.867
it can be no issue at all to see when exactly a call was executed, and maybe correlate it to otle rlogfiles of the application.
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
tim=12568091341788 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
tim=12568091343769 42 XCTEND
but mrwhen wasn't happy (yet):
mrwhen: no START value in file 'bx1.trc'
mrwhen: no DEP value in file 'bx1.trc'
mrwhen: file 'bx1.trc' contains no timestamp line
The START value is not documented right now, but it can be easily guessed mrwhen needs a real timestamp to correlate the tim values. The next try is:
*** 2020-11-26 10:06:01.867
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
tim=12568091341788 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
tim=12568091343769 42 XCTEND
and now mrwhen changes it's mind slightly:
mrwhen: no DEP value in file 'bx1.trc'
mrwhen: file 'bx1.trc' contains no tim-containing line
No complain about START anymore, and it doesn't see any tim-containing line? I'm very sure I see tim= there.
*** 2020-11-26 10:06:01.867
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
XCTEND tim=12568091341788 e=2 dep=0 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ..
XCTEND tim=12568091343769 e=1 dep=0 42 XCTEND
Now mrwhen still complains
mrwhen: no DEP value in file 'bx1.trc'
But the result is useful now:
2020-11-26 10:06:01.867000 2020-11-26 10:06:01.867000 *** 2020-11-26 10:06:01.867
END-TIM LINE SQL_ID CALL-NAME STATEMENT-TEXT
-----------------------------------------------------------------------------
2020-11-26T10:06:01.867000 2020-11-26T10:06:01.867000 XCTEND tim=12568091341788 e=2 dep=0 36 5kpbj024phrws EXEC /*Begin.Work*/ SELECT ...
2020-11-26T10:06:01.868981 2020-11-26T10:06:01.868981 XCTEND tim=12568091343769 e=1 dep=0 42 XCTEND
sed -E 's/XCTEND t.{37}//'
Still I have some wishes for mrskew extensions, but they are not part of this post.