home‎ > ‎monitoring‎ > ‎

infx sqltrace

This command is used to change SQL tracing settings, as well as view statement history 

usage

turn on global SQL tracing

infx sqltrace func=globalon traces tracesize [ mode=global|user scope=low|medium|high ]
     turn on gloabl sql tracing
       required:
         traces - the number of traces to store
         tracesize - the size in kb of storage for each trace
       optional:
         mode - mode to be set
         scope - the scope of the tracing

turn off global SQL tracing

infx sqltrace func=globaloff
     turn off global sql tracing

turn on user SQL tracing

infx sqltrace func=useron sid
     turn on user sql tracing
       required:
         sid - database session id

turn off user SQL tracing

infx sqltrace func=useroff sid
     turn off user sql tracing
       required:
         sid - database session id

clear user SQL tracing

infx sqltrace func=userclear sid
     clear user sql tracing cache
       required:
         sid - database session id

show SQL statement execution history

infx sqltrace func=history stmt
     show sql tracing history
       required:
         stmt - the sql statement to view
         photo - photo file to read information from

generate SQL explain output for a statement

infx sqltrace func=explain stmt db
     show sql explain
       required:
         stmt - the sql statement to view
         db - select database
         photo - photo file to read information from

examples

turn global tracing on

demo1b@bobii:/home/informix>infx sqltrace func=globalon traces=1000 tracesize=2

Database selected.

SQL Tracing ON: ntraces=1000, size=2008, level=Med, mode=Global.

1 row(s) retrieved.

Database closed.

Show information about one statement

demo1b@bobii:/home/informix>infx sqltrace func=history stmt=3268

Statement # 3268:     @ 0x4d75f8a8

 Database:        0x100004
 Statement text:
  select ss.sid, ss.username, ss.hostname, stn2.tabname, sl.tabname object,
    sl.type, count(*) num
                from syssessions ss, syslocks sl, systabnames stn1, systabnames stn2,
    sysptnhdr sph
                where sl.owner=ss.sid
                and sl.dbsname = "bartest"
                and sl.tabname=stn1.tabname and sl.dbsname=stn1.dbsname
                and stn1.partnum=sph.partnum
                and sph.lockid=stn2.partnum
                group by 1,2,3,4,5,6

 Statement information:
  Sess_id  User_id  Stmt Type        Finish Time    Run Time   TX Stamp   PDQ
  321      502      SELECT           23:55:42       0.0000     21a4b8     0

 Statement Statistics:
  Page       Buffer     Read       Buffer     Page       Buffer     Write
  Read       Read       % Cache    IDX Read   Write      Write      % Cache
  0          0          0.00       0          0          0          0.00

  Lock       Lock       LK Wait    Log        Num        Disk       Memory
  Requests   Waits      Time (S)   Space      Sorts      Sorts      Sorts
  0          0          0.0000     0.000 B    0          0          0

  Total      Total      Avg        Max        Avg        I/O Wait   Avg Rows
  Executions Time (S)   Time (S)   Time (S)   IO Wait    Time (S)   Per Sec
  1          0.0000     0.0000     0.0000     0.000000   0.000000   99350.1689

  Estimated  Estimated  Actual     SQL        ISAM       Isolation  SQL
  Cost       Rows       Rows       Error      Error      Level      Memory
  91         13         0          0          0          CR         301784

generate SQL explain output for a statement

demo1b@bobii:/home/informix>infx sqltrace func=explain stmt=4592 db=monitor_jgh1

QUERY: (OPTIMIZATION TIMESTAMP: 04-11-2012 14:22:00)
------
select count(distinct mon_date) from objectdailysum

Estimated Cost: 424
Estimated # of Rows Returned: 1

  1) informix.objectdailysum: INDEX PATH

    (1) Index Name: informix.ix1_ods
        Index Keys: dbname tabname mon_date   (Key-Only)  (Serial, fragments: ALL)