Post

Visualizzazione dei post da ottobre, 2017

Individuare Tabelle in Lock

Per individuare la sessione in attesa  select *  from V$SESSION_WAIT  where EVENT = 'enqueue'; SID identifier of session holding the lock P1, P2, P3 determine the resource when event = 'enqueue' SECONDS_IN_WAIT gives how long the wait did occurs SELECT substr(DECODE(request,0,'Holder: ','Waiter: ')||sid,1,17) sess,id1, id2, lmode, request, type, inst_id FROM GV$LOCK WHERE (id1, id2, type) IN (SELECT id1, id2, type FROM GV$LOCK WHERE request>0) ORDER BY id1, request Per individuare la sessione bloccante e quindi che trattiene le risorse select * from v$lock  where block=1; select sid, serial#, username from v$session where sid in (select blocking_session from V$Session ); sid, serial# sono gli identificativi della sessione oracle LOCKWAIT address of the lock waiting, otherwise null ROW_WAIT_OBJ# object identified of the object we are waiting on (object_id of dba_objects)  ROW_WAIT_FILE#, ROW_WAIT_BLOCK#, ROW_WAIT_ROW# sono i file_id , block_id and 

Monitoraggio Processi e Query- Individuare lo stato di EVENT

Vedere gli eventi della session da analizzare SELECT username, sid , serial# , osuser, status FROM  v$session WHERE trunc (logon_time) = to_date( '28/10/2017' , 'dd/mm/yyyy' ) AND   machine = 'nome_server' AND service_name = 'nome_sid' ; SELECT   event   FROM  V$session; SELECT   event  FROM  v$session_wait Di seguito la query per individuare il processo del sistema operativo (spid): SELECT spid FROM   v$process WHERE NOT EXISTS (SELECT 1                   FROM v$session                   WHERE paddr = addr); Per identificate la sessione in corso. SELECT s.sid, s.serial#, p.spid FROM v$process p, v$session s WHERE p.addr = s.paddr AND s.username = 'schema' ; Per individuare i parametri da killare select 'alter system kill session '||''''|| s.sid ||','|| s.serial# ||''';' FROM v$session s,v$process p WHERE p.addr=s.paddr AND s.sid = and p.pr

Dimensione di una tabella

Di seguito alcune query per individuare le dimensioni in MB di una tabella. select segment_name table_name, sum (bytes)/( 1024 * 1024 ) table_size_meg from user_extents where segment_type= 'TABLE' and segment_name = 'nome_tabella' group by segment_name; SELECT owner, segment_name, segment_type, tablespace_name, bytes/ 1048576 MB, initial_extent, next_extent, extents , pct_increase FROM DBA_SEGMENTS WHERE OWNER = 'BILL' AND   SEGMENT_NAME = ' nome_tabella ' AND SEGMENT_TYPE = 'TABLE' ; select segment_name,segment_type,bytes/ 1024 / 1024 MB from dba_segments where segment_type= 'TABLE' and segment_name= ' nome_tabella ' ; select table_name, num_rows, AVG_ROW_LEN , num_rows*AVG_ROW_LEN/ 1024 / 1024 space_in_MB from dba_tables where table_name = ' nome_tabella '

Statistiche di una tabella da Toad

Immagine
Accedere a Toad sotto Schema Browser, selezionare la tabella  e il tab Stats/Size. Di seguito si vede l'ultimo lancio di statistiche su una tabella:  Per lanciare le statistiche pulsante destro sulla tabella e selezionare "Analyze table".