I imported a trace file using
SELECT * INTO trace_table FROM ::fn_trace_gettable('c:\my_trace.trc', default)
While analyzing my imported trace file i noticed that certain select statements take a significant amount of time (duration) and cpu but at the end do not return any rows (RowsCount == NULL
).
SELECT TextData, ClientProcessID, EventClass
, Duration, StartTime, EndTime
, Reads, Writes, CPU, RowCounts
, EventSequence, TextData_md5_hash
, ApplicationName, SPID
FROM MyImportedTrace
WHERE
TextData_md5_hash in (0x4A943F266010BDD2A47179DC3481BC7F)
ORDER BY SPID, StartTime, EventSequence
Example
Test in query window
If i copy the same query from the TextData
-Field into a query window i get a lot of rows (>200000)
Questions
- What might be a reason that the query did not return any rows?
- Was the query terminated ?
- How do i recognize failed query executions in a trace file?
Update / Edit after Answer accepted
This query
Use MyDatabase
SELECT ti.EventClass, te.Eventname, Count(*) as CountAsterisk
, Sum(ti.RowCounts) as RowCountsSum
, Sum(ti.Duration/1000) as DurationSum_ms
, Avg(ti.Duration/1000) as DurationAvg_ms
FROM TraceImport ti
Left JOIN TraceEvents te
ON ti.EventClass = te.EventTraceID
Group By ti.EventClass, te.Eventname
Order By EventClass
Returns this result