Finding Long Operations (E.g. Full Table Scans)
Finding Long Operations (E.g. Full Table Scans)
Sometimes things are going slow, but it's because it is blocked waiting for a lock:-select object_name, object_type, session_id, type, -- Type or system/user lock lmode, -- lock mode in which session holds lock request, block, ctime -- Time since current mode was granted from v$locked_object, all_objects, v$lock where v$locked_object.object_id = all_objects.object_id AND v$lock.id1 = all_objects.object_id AND v$lock.sid = v$locked_object.session_id order by session_id, ctime desc, object_name;
select * from v$access where sid=''; select * from v$locked_object where object_id=''; select * from sys.sess_waits where holding_session not in(select waiting_session from sys.sess_waits); --This one shows SQL that is currently "ACTIVE":-select S.USERNAME, s.sid, s.osuser, t.sql_id, sql_text from v$sqltext_with_newlines t,V$SESSION s where t.address =s.sql_address and t.hash_value = s.sql_hash_value and s.status = 'ACTIVE' and s.username <> 'SYSTEM' order by s.sid,t.piece --finding long operations (e.g. full table scans)-SELECT sid, to_char(start_time,'hh24:mi:ss') stime, message,( sofar/totalwork)* 100 percent FROM v$session_longops WHERE sofar/totalwork < 1 --it will give you queries currently running for more than 60 seconds-select s.username,s.sid,s.serial#,s.last_call_et/60 mins_running,q.sql_text from v$session s join v$sqltext_with_newlines q on s.sql_address = q.address where status='ACTIVE' and type <>'BACKGROUND' and last_call_et> 60 order by sid,serial#,q.piece;
SELECT * FROM v$locked_object; SELECT * FROM v$lock; select * from fnd_product_installations where patch_level like ''; TO FIND REQUEST SUBMITTED BY PARTICULAR USER SELECT user_concurrent_program_name, responsibility_name, to_char(request_date, 'DD-MM-YYYY HH:MI:SS'), to_char(actual_completion_date, 'DD-MM-YYYY HH:MI:SS'), argument_text, request_id, phase_code, outfile_name, logfile_name, status_code FROM fnd_concurrent_requests fcr, fnd_concurrent_programs_tl fcp, fnd_responsibility_tl fr, fnd_user fu WHERE fcr.concurrent_program_id = fcp.concurrent_program_id and fcr.responsibility_id = fr.responsibility_id and fcr.requested_by = fu.user_id and user_name = upper(:user_name) ORDER BY REQUEST_DATE DESC; QUERY TO FIND TRACE FILE FOR A REQUEST SELECT 'Request id: '||request_id , 'Trace id: '||oracle_Process_id, 'Trace Flag: '||req.enable_trace, 'Trace Name: '||dest.value||'/'||lower(dbnm.value)||'_ora_'|| oracle_process_id||'.trc', --'Prog. Name: '||prog.user_concurrent_program_name, 'File Name: '||execname.execution_file_name|| execname.subroutine_name , 'Status : '||decode(phase_code,'R','Running') ||'-'|| decode(status_code,'R','Normal'), 'SID Serial: '||ses.sid||','|| ses.serial#, 'Module : '||ses.module from fnd_concurrent_requests req, v$session ses, v$process proc, v$parameter dest, v$parameter dbnm, fnd_concurrent_programs_vl prog, fnd_executables execname where req.request_id = &request
req.oracle_process_id=proc.spid(+) proc.addr = ses.paddr(+) dest.name='user_dump_dest' dbnm.name='db_name' req.concurrent_program_id = prog.concurrent_program_id req.program_application_id = prog.application_id prog.application_id = execname.application_id prog.executable_id=execname.executable_id;
To find request group for particular concurrent program select fcp.user_concurrent_program_name, fcp.concurrent_program_name, frg.request_group_name from fnd_request_group_units frgu, fnd_concurrent_programs_vl fcp, fnd_request_groups frg where fcp.user_concurrent_program_name='Jacmel 810 Report' and frgu.request_unit_id = fcp.concurrent_program_id and frg.request_group_id = frgu.request_group_id
select p.spid,s.sid,s.serial#,s.username,s.status,s.last_call_et,p.program,p.t erminal,logon_time,module,s.osuser from V$process p,V$session s where s.paddr = p.addr and s.status = 'ACTIVE' and s.username not like '%SYS%'; --alter system kill session '1938,260'; select * from v$session where paddr in (select addr from v$process where spid = YOUR_OS_PID); QUERY TO KNOW APPLICATIONS PATCH LEVEL
select patch_level, application_name from fnd_product_installations fpi , fnd_application_tl fat where patch_level is not null and fpi.application_id = fat.application_id order by application_name;
SELECT
'select count(1) ' || table_name || ' from ' || owner || '.' || table_name || ' where last_update_date > sysdate - 1 and last_updated_by = 11531;' FROM all_tables AT WHERE EXISTS ( SELECT 1 FROM all_tab_columns atc WHERE atc.table_name = AT.table_name AND atc.owner = AT.owner AND atc.column_name = 'LAST_UPDATED_BY') AND EXISTS ( SELECT 1 FROM all_tab_columns atc WHERE atc.table_name = AT.table_name AND atc.owner = AT.owner AND atc.column_name = 'LAST_UPDATE_DATE');
DECODE (cp.user_concurrent_program_name, 'Report Set', 'Report Set:' || cr.description, cp.user_concurrent_program_name ) NAME, argument_text, cr.resubmit_interval, NVL2 (cr.resubmit_interval, 'PERIODICALLY', NVL2 (cr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE') ) schedule_type, DECODE (NVL2 (cr.resubmit_interval, 'PERIODICALLY', NVL2 (cr.release_class_id, 'ON SPECIFIC DAYS', 'ONCE') ), 'PERIODICALLY', 'EVERY ' || cr.resubmit_interval || ' ' || cr.resubmit_interval_unit_code || ' FROM ' || cr.resubmit_interval_type_code || ' OF PREV RUN', 'ONCE', 'AT :' || TO_CHAR (cr.requested_start_date, 'DD-MON-RR HH24:MI'), 'EVERY: ' || fcr.class_info ) schedule, fu.user_name, requested_start_date FROM apps.fnd_concurrent_programs_tl cp, apps.fnd_concurrent_requests cr, apps.fnd_user fu, apps.fnd_conc_release_classes fcr WHERE cp.application_id = cr.program_application_id AND cp.concurrent_program_id = cr.concurrent_program_id AND cr.requested_by = fu.user_id AND cr.phase_code = 'P' AND cr.requested_start_date > SYSDATE AND cp.LANGUAGE = 'US' AND fcr.release_class_id(+) = cr.release_class_id AND fcr.application_id(+) = cr.release_class_app_id;
QUERY TO CHECK LOCKS select s.sid, s.serial#, p.spid from v$session s, v$process p where s.paddr = p.addr and s.sid in (select SESSION_ID from v$locked_object);
QUERY TO KNOW INSTALLED PRODUCTS IN APPLICATIONS: select fa.APPLICATION_SHORT_NAME, fpi.PATCH_LEVEL, DECODE(fpi.STATUS, 'I','Installed', 'S','Shared', 'N', 'Inactive', fpi.STATUS) Status , fpi.DB_STATUS from fnd_product_installations fpi,FND_APPLICATION fa where fpi.APPLICATION_ID in ( select APPLICATION_ID from FND_APPLICATION) and fa.APPLICATION_ID=fpi.APPLICATION_ID;
Query: Find scheduled or on hold concurrent requests: select request_id from fnd_concurrent_requests where status_code in ('Q','I') and requested_start_date > SYSDATE and hold_flag = 'N'; Checking the duplicated schedules of the same program with the same arguments: SELECT request_id, NAME, argument_text, user_name FROM (SELECT cr.request_id, DECODE (cp.user_concurrent_program_name, 'Report Set', 'Report Set:' || cr.description, cp.user_concurrent_program_name ) NAME, argument_text, fu.user_name FROM apps.fnd_concurrent_programs_tl cp, apps.fnd_concurrent_requests cr, apps.fnd_user fu WHERE cp.application_id = cr.program_application_id AND cp.concurrent_program_id = cr.concurrent_program_id AND cr.requested_by = fu.user_id AND cr.phase_code = 'P' AND cr.requested_start_date > SYSDATE AND cp.LANGUAGE = 'US' AND fu.user_name NOT LIKE 'PPG%') t1 WHERE EXISTS ( SELECT 1 FROM (SELECT cr.request_id, DECODE (cp.user_concurrent_program_name, 'Report Set', 'Report Set:' || cr.description, cp.user_concurrent_program_name ) NAME, argument_text, fu.user_name FROM apps.fnd_concurrent_programs_tl cp, apps.fnd_concurrent_requests cr, apps.fnd_user fu WHERE cp.application_id = cr.program_application_id AND cp.concurrent_program_id = cr.concurrent_program_id
AND cr.requested_by = fu.user_id AND cr.phase_code = 'P' AND cr.requested_start_date > SYSDATE AND cp.LANGUAGE = 'US' AND fu.user_name NOT LIKE 'PPG%') t2 WHERE t1.NAME = t2.NAME AND t1.argument_text = t2.argument_text AND t1.user_name = t2.user_name GROUP BY NAME, argument_text, user_name HAVING COUNT (*) > 1) ORDER BY user_name, NAME; Average pending time per request: SELECT TO_CHAR (actual_start_date, 'DD-MON-YYYY') DAY, concurrent_queue_name, (SUM ( ( actual_start_date - (CASE WHEN requested_start_date > request_date THEN requested_start_date ELSE request_date END ) ) * 24 * 60 * 60 ) ) / COUNT (*) "Wait_Time_per_Req_in_Secs" FROM apps.fnd_concurrent_requests cr, apps.fnd_concurrent_processes fcp, apps.fnd_concurrent_queues fcq WHERE cr.phase_code = 'C' AND cr.actual_start_date IS NOT NULL AND cr.requested_start_date IS NOT NULL AND cr.controlling_manager = fcp.concurrent_process_id AND fcp.queue_application_id = fcq.application_id AND fcp.concurrent_queue_id = fcq.concurrent_queue_id GROUP BY TO_CHAR (actual_start_date, 'DD-MON-YYYY'), concurrent_queue_name ORDER BY 2; Checking which manager is going to execute a program: SELECT user_concurrent_program_name, user_concurrent_queue_name FROM apps.fnd_concurrent_programs_tl cp, apps.fnd_concurrent_queue_content cqc, apps.fnd_concurrent_queues_tl cq WHERE cqc.type_application_id(+) = cp.application_id AND cqc.type_id(+) = cp.concurrent_program_id AND cqc.type_code(+) = 'P' AND cqc.include_flag(+) = 'I' AND cp.LANGUAGE = 'US' AND cp.user_concurrent_program_name = '&USER_CONCURRENT_PROGRAM_NAME' AND NVL (cqc.concurrent_queue_id, 0) = cq.concurrent_queue_id AND NVL (cqc.queue_application_id, 0) = cq.application_id
AND cq.LANGUAGE = 'US'; To see all the pending / Running requests per each manager wise SELECT request_id, phase_code, status_code, user_name, user_concurrent_queue_name FROM apps.fnd_concurrent_worker_requests cwr, apps.fnd_concurrent_queues_tl cq, apps.fnd_user fu WHERE (cwr.phase_code = 'P' OR cwr.phase_code = 'R') AND cwr.hold_flag != 'Y' AND cwr.requested_start_date <= SYSDATE AND cwr.concurrent_queue_id = cq.concurrent_queue_id AND cwr.queue_application_id = cq.application_id AND cq.LANGUAGE = 'US' AND cwr.requested_by = fu.user_id ORDER BY 5; Checking the incompatibilities between the programs: SELECT a2.application_name, a1.user_concurrent_program_name, DECODE (running_type, 'P', 'Program', 'S', 'Request set', 'UNKNOWN' ) "Type", b2.application_name "Incompatible App", b1.user_concurrent_program_name "Incompatible_Prog", DECODE (to_run_type, 'P', 'Program', 'S', 'Request set', 'UNKNOWN' ) incompatible_type FROM apps.fnd_concurrent_program_serial cps, apps.fnd_concurrent_programs_tl a1, apps.fnd_concurrent_programs_tl b1, apps.fnd_application_tl a2, apps.fnd_application_tl b2 WHERE a1.application_id = cps.running_application_id AND a1.concurrent_program_id = cps.running_concurrent_program_id AND a2.application_id = cps.running_application_id AND b1.application_id = cps.to_run_application_id AND b1.concurrent_program_id = cps.to_run_concurrent_program_id AND b2.application_id = cps.to_run_application_id AND a1.language = 'US' AND a2.language = 'US' AND b1.language = 'US' AND b2.language = 'US';
QUERY TO CHECK TIME TAKEN BY EACH CONCURRENT REQUEST select fcp.description "Description", concurrent_program_name "Program", trunc(avg((to_number(to_char(actual_completion_date,'SSSSS')) to_number(to_char(actual_start_date,'SSSSS')))/60),2) in Min." fnd_concurrent_programs_vl fcp, fnd_concurrent_requests fcr fcp.application_id = fcr.program_application_id and fcp.concurrent_program_id = fcr.concurrent_program_id and to_char(actual_completion_date,'DD-MON-YY') = to_char(actual_start_date,'DD-MON-YY') by concurrent_program_name, fcp.description by fcp.description;
group order
R12:
select b.bug_number BUG, b.LAST_UPDATE_DATE LDATE, decode(bug_number, 4440000, 'Oracle Applications Release 12 Maintenance Pack', 5082400, '12.0.1 Release Update Pack (RUP1)', 5484000, '12.0.2 Release Update Pack (RUP2)', 6141000, '12.0.3 Release Update Pack (RUP3)', 6435000, '12.0.4 RELEASE UPDATE PACK (RUP4)', 5907545, 'R12.ATG_PF.A.DELTA.1', 5917344, 'R12.ATG_PF.A.DELTA.2', 6077669, 'R12.ATG_PF.A.DELTA.3', 6272680, 'R12.ATG_PF.A.DELTA.4', 7237006, 'R12.ATG_PF.A.DELTA.6', 6728000, '12.0.6 RELEASE UPDATE PACK (RUP6)' ) PATCH from AD_BUGS b where b.BUG_NUMBER in ('4440000','5082400','5484000','6141000','6435000', '5907545','5917344','6077669','6272680','7237006','6728000') order by patch;
QUERY TO KNOW PREVILEGES FOR A USER SELECT LPAD(' ', 2*level) || granted_role "USER PRIVS" FROM ( SELECT NULL grantee, username granted_role FROM dba_users WHERE username LIKE UPPER('%&uname%') UNION SELECT grantee, granted_role FROM dba_role_privs UNION SELECT grantee, privilege FROM dba_sys_privs) START WITH grantee IS NULL CONNECT BY grantee = prior granted_role;
select /*+ ordered */ w1.sid waiting_session, h1.sid holding_session, w.kgllktype lock_or_pin, w.kgllkhdl address, decode(h.kgllkmod, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive', 'Unknown') mode_held, decode(w.kgllkreq, 0, 'None', 1, 'Null', 2, 'Share', 3, 'Exclusive', 'Unknown') mode_requested from dba_kgllock w, dba_kgllock h, v$session w1, v$session h1 where (((h.kgllkmod != 0) and (h.kgllkmod != 1) and ((h.kgllkreq = 0) or (h.kgllkreq = 1))) and (((w.kgllkmod = 0) or (w.kgllkmod= 1)) and ((w.kgllkreq != 0) and (w.kgllkreq != 1)))) and w.kgllktype = h.kgllktype and w.kgllkhdl = h.kgllkhdl and w.kgllkuse = w1.saddr and h.kgllkuse = h1.saddr;
WHERE TABLESPACE_NAME ='APPS_UNDOTS1'; QUERY TO FIND THE PRINTER NAME FOR THE REQUEST SELECT fcr.request_id, fcp.concurrent_program_name, fcr.printer FROM fnd_concurrent_requests fcr, fnd_concurrent_programs fcp WHERE fcr.concurrent_program_id=fcp.concurrent_program_id AND fcr.printer='&printer'; QUERY TO FIND THE MANAGERS AND STATUS select concurrent_queue_id,concurrent_queue_name, running_processes,max_processes,cache_size, target_node, node_name from fnd_concurrent_queues where enabled_flag='Y';
TO FIND OS PID FROM SID SELECT P.SPID, S.SID, S.SERIAL# FROM V$PROCESS P, V$SESSION S WHERE P.ADDR = S.PADDR AND S.SID = 2500;
total_blocks*16/1024 AS total_MB, used_blocks *16/1024 AS used_MB , free_blocks *16/1024 AS free_MB FROM v$sort_segment; ********************************************** SELECT SUM (u.blocks * blk.block_size) / 1024 / 1024 "Mb. in sort segments" , (hwm.MAX Mark" * blk.block_size) / 1024 / 1024 "Mb. High Water
FROM v$sort_usage u ,
(SELECT block_size FROM DBA_TABLESPACES WHERE CONTENTS = 'TEMPORARY' ) blk , (SELECT segblk# + blocks MAX FROM v$sort_usage WHERE segblk# = (SELECT MAX (segblk#) FROM v$sort_usage ) ) hwm GROUP BY hwm.MAX * blk.block_size / 1024 / 1024;
SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_used, D.mb_total - SUM (A.used_blocks * D.block_size) / 1024 / 1024 mb_free FROM ( SELECT FROM WHERE B.name, C.block_size, SUM (C.bytes) / 1024 / 1024 mb_total v$tablespace B, v$tempfile C B.ts#= C.ts# v$sort_segment A,