Trace Group Simular Statemments

  • Hey

    I run serveral traces and have a problem analyzing data

    I know that there is some scripts out there, as can give me this statement has ran for x times and took y time.

    Only issue is that vaules may differ in statements so my select returns one pr row.

    Anyone? Please?

  • i create a a view for every trace i create; it's just much easier to access.

    from there, i can group the data however i need to, since it's just an object.

    --SELECT * from sys.traces

    declare @TraceIDToReview int

    declare @path varchar(255)

    declare @cmd varchar(max)

    SET @TraceIDToReview = 1 --this is the trace you want to review!

    SELECT @path = path from sys.traces WHERE id = @TraceIDToReview

    SET @cmd = '

    CREATE VIEW MyCustomTrace' + CONVERT(VARCHAR,@TraceIDToReview) + ' AS

    SELECT

    TE.name As EventClassDescrip,

    v.subclass_name As EventSubClassDescrip,

    T.*

    FROM ::fn_trace_gettable(' + @path + ', default) T

    LEFT OUTER JOIN sys.trace_events TE ON T.EventClass = TE.trace_event_id

    LEFT OUTER JOIN sys.trace_subclass_values V

    ON T.EventClass = V.trace_event_id AND T.EventSubClass = V.subclass_value'

    PRINT(@cmd)

    EXEC(@cmd)

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Yes, but this only allows me to group on class / type of statement.

    I would like to group simular statements

    select * from table1 where id = 1 order by id

    select * from table1 where id = 4 order by id

    is in my perspective same statement, I need some statement that can "mask" criteria..

    I can take a substring and cut all from where, but I need to know coulmns are used, in order to validate indexes, and also if coulmns are not same, it might be an other action in application

  • SpiderDK (5/13/2013)


    Yes, but this only allows me to group on class / type of statement.

    I would like to group simular statements

    select * from table1 where id = 1 order by id

    select * from table1 where id = 4 order by id

    is in my perspective same statement, I need some statement that can "mask" criteria..

    I can take a substring and cut all from where, but I need to know coulmns are used, in order to validate indexes, and also if coulmns are not same, it might be an other action in application

    i'm already thinking the trace is the wrong tool for for validating indexes. the WHERE statement tells you what columns are used to find the index,and any SELECT * is going to bring in the clustered index to get all columns anyway, i'd think.

    nothing int he trace will tell you but not what index was used, or that is potentially missing.

    instead of a trace, you really need to look at the dynamic management views instead.

    it depends on what you are really trying to do;

    Are you looking for poorly performing queries?

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I have a application, I want to know WHERE my users are waiting.

    This will be done by a trace, and import to table..

    There I want to run a statement showning with total duration, number of executions and avarage duration..

    This will clearly show me WHERE time is spent

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply