Home » RDBMS Server » Performance Tuning » last queries (oracle 9i windows 2000 server sp4)
last queries [message #294206] Wed, 16 January 2008 17:05 Go to next message
agemaia
Messages: 11
Registered: January 2008
Junior Member
hi,

is there any method of finding queries launched or at least last queries launched?

thanks.
Re: last queries [message #294218 is a reply to message #294206] Wed, 16 January 2008 20:56 Go to previous message
rleishman
Messages: 3724
Registered: October 2005
Location: Melbourne, Australia
Senior Member
Here's one I use:
SET LINES 32767 LONG 65536 FEEDBACK OFF TRIMSPOOL ON HEADING ON PAGES 24

UNDEFINE search_string
UNDEFINE sql_hash_value
UNDEFINE sql_address
UNDEFINE sql_child_number
UNDEFINE sql_id
UNDEFINE sid

CLEAR column

BREAK ON SID SKIP PAGE

COLUMN username FORMAT A10 WRAP
COLUMN prog_event FORMAT A35 WRAP
COLUMN run_time FORMAT A10 JUSTIFY RIGHT
COLUMN sid FORMAT A4 NEW_VALUE sid
COLUMN status FORMAT A10
COLUMN sql_fulltext FORMAT a32767

ACCEPT search_string PROMPT "Search for: "
column st format a1 trunc

SELECT  to_char(s.sid) AS sid
,       s.username || chr(10) || s.osuser AS username
,       s.status || chr(10) || 'PID:' || p.spid AS status
,       lpad(
                to_char(
                        trunc(24*(sysdate-s.logon_time))
                ) ||
                to_char(
                        trunc(sysdate) + (sysdate-s.logon_time)
                ,       ':MI:SS'
                )
        , 10, ' ') AS run_time
,       s.program ||  chr(10) || s.event AS prog_event
,       cursor (
                SELECT  sql_fulltext 
                FROM    v$sql t
                WHERE   t.hash_value    = s.sql_hash_value
                AND     t.address       = s.sql_address
                AND     t.child_number  = s.sql_child_number
                AND     t.sql_id        = s.sql_id
                UNION ALL
                SELECT  chr(10) || to_clob(max(message))
                FROM    v$session_longops t
                WHERE   t.sql_hash_value    = s.sql_hash_value
                AND     t.sql_address       = s.sql_address
                AND     t.sql_id        = s.sql_id
                AND     t.sid           = s.sid
                AND     t.totalwork     > t.sofar
        ) AS st
FROM    v$session s
JOIN    v$process p ON (p.addr = s.paddr)
WHERE   s.username IS NOT NULL
AND     audsid != sys_context('USERENV','SESSIONID')
AND     upper(
                s.osuser || '|' ||
                s.program || '|' ||
                s.event || '|' ||
                s.sid || '|' ||
                s.username || '|' ||
                p.spid
        ) LIKE upper('%&search_string.%')
ORDER BY
        sid
/

CLEAR BREAK
SET LINES 80 FEEDBACK ON
prompt


Ross Leishman
Previous Topic: index monitoring
Next Topic: SQL statement takes too long to run
Goto Forum:
  


Current Time: Mon Dec 05 06:51:30 CST 2016

Total time taken to generate the page: 0.09908 seconds