rudydelhaye
8/6/2019 - 7:36 AM

ORCL - Long Query

set lines 2000
col session format a30
col machine format a30
col program format a30
SELECT vs.SID || ',' || vs.serial# "Session", vs.username, vs.last_call_et AS "Duree (s)",
vs.program, vs.machine, vs.sql_id, vs.SQL_HASH_VALUE
FROM v$session vs, v$process vp
WHERE vs.paddr = vp.addr AND vs.status = 'ACTIVE' AND vs.username IS NOT NULL AND vs.last_call_et > 200
ORDER BY vs.last_call_et;
SELECT SQL_ID,EXECUTIONS,ELAPSED_TIME,CPU_TIME FROM V$SQL ORDER BY ELAPSED_TIME;
SET LINES 200;
	SELECT 
	SQL_ID,
	EXECUTIONS,
	FIRST_LOAD_TIME,
	LAST_LOAD_TIME,
	LAST_ACTIVE_TIME,
	ELAPSED_TIME/1000000 TOTAL_ELAPSED_TIME_SEC,
	ELAPSED_TIME/1000000/EXECUTIONS ELAPSED_TIME_SEC_PER_EXEC,
	CPU_TIME/1000000 TOTAL_CPU_TIME_SEC,
	CPU_TIME/1000000/EXECUTIONS CPU_TIME_SEC
FROM
	V$SQL
WHERE
	SQL_ID='6mcpb06rctk0x';
SET LONG 20000 LONGCHUNKSIZE 20000 PAGESIZE 0 LINESIZE 1000 FEEDBACK OFF VERIFY OFF TRIMSPOOL ON

select SQL_TEXT fulltext from v$sqltext where sql_id='b9zpcc16t881z' order by PIECE;
alter session set nls_date_format = 'dd/mm/yyyy hh24:mi';
set pages 50000 lines 32767
col target format a25
col opname format a40
select sid
      ,opname
      ,target
      ,round(sofar/totalwork*100,2)   as percent_done
      ,start_time
      ,last_update_time
      ,time_remaining
from
       v$session_longops
/
set pages 50000 lines 32767
col USERNAME for a10
col MACHINE for a15
col PROGRAM for a40

SELECT USERNAME,machine,inst_id,sid,serial#,PROGRAM,
to_char(logon_time,'dd-mm-yy hh:mi:ss AM')"Logon Time",
ROUND((SYSDATE-LOGON_TIME)*(24*60),1) as MINUTES_LOGGED_ON,
ROUND(LAST_CALL_ET/60,1) as Minutes_FOR_CURRENT_SQL
From gv$session
WHERE STATUS='ACTIVE'
AND USERNAME IS NOT NULL and ROUND((SYSDATE-LOGON_TIME)*(24*60),1) > 60
ORDER BY MINUTES_LOGGED_ON DESC;
select  * from v$session_longops  where time_remaining > 0 and sid=266;