вторник, 20 января 2015 г.

Restart QMon process

Event "Streams AQ: waiting for time management or cleanup tasks" in running state

  1. SELECT event, state, COUNT(*) AS cnt, sum(seconds_in_wait) AS wait_in_seconds
  2. FROM v$session_wait
  3. WHERE event LIKE 'Streams AQ%'
  4. GROUP BY event, state;
  5.  
  6. select * from GV$QMON_TASKS
  7.  
  8. select * from GV$QMON_SERVER_STATS
  9.  
  10. select isdefault from v$parameter where name='aq_tm_processes';

Restart QMon process

  1. show parameter aq_tm_processes
  2.  
  3. alter system set aq_tm_processes = 0;
  4.  
  5. alter system set aq_tm_processes = 1;
  6.  
  7. show parameter aq_tm_processes
  8.  
  9. alter system reset aq_tm_processes scope=spfile;

Shrinking undo tablespace

Useful links


Undo tablespace

The simplest way to reclaim space from the undo tablespace is to create a new undo tablespace:
  1. CREATE UNDO TABLESPACE undotbs2 DATAFILE '/u01/app/oracle/oradata/DB11G/undotbs02.dbf' SIZE 2G AUTOEXTEND ON NEXT 1M;
  2.  
  3. ALTER SYSTEM SET UNDO_TABLESPACE=undotbs2;
  4.  
  5. DROP TABLESPACE undotbs1 INCLUDING CONTENTS AND DATAFILES;

Undo segments in DBA_ROLLBACK_SEGS view

  1. select owner, segment_name, tablespace_name, status
  2. --select *
  3. from dba_rollback_segs
  4. where 1 = 1
  5. --and tablespace_name='UNDOTBS1'
  6. --and status='ONLINE'
  7. --and segment_name ='_SYSSMU51_2438556163$'
  8. ;

Who holds UNDO tablespace

  1. select
  2. substr(a.os_user_name,1,15) "OS User",
  3. substr(a.oracle_username,1,8) "DB User",
  4. substr(b.owner,1,8) "Schema",
  5. substr(b.object_name,1,20) "Object Name",
  6. substr(b.object_type,1,10) "Type",
  7. substr(c.segment_name,1,15) "RBS",
  8. substr(d.used_urec,1,12) "# of Records",
  9. e.sid,
  10. e.serial#
  11. from v$locked_object a,
  12. dba_objects b,
  13. dba_rollback_segs c,
  14. v$transaction d,
  15. v$session e
  16. where
  17. a.object_id = b.object_id
  18. and
  19. a.xidusn = c.segment_id
  20. and
  21. a.xidusn = d.xidusn
  22. and
  23. a.xidslot = d.xidslot
  24. and
  25. d.addr = e.taddr;

Issue: Drop UNDO including datafiles does not delete files at OS level

Find oracle process which hold file :
  1. [root@hostname][/]:lsof | grep undo | grep deleted
  2. oracle 3818 oracle 258u REG 8,65 32421978112 17089 /u01/app/oracle/oradata/DB11G/undotbs01.dbf (deleted)
  3.  
  4. sqlplus / as sysdba
  5. SQL> SELECT sid, serial#, process, terminal, program, event FROM v$session WHERE process in ('3818')
Look at this SID and it event, and find solution how to release hold of file by this session, for example I have issue with Restart QMon process

пятница, 9 января 2015 г.

Solving event I/O and Cluster wait and freeing wasted space in LOBs

Issue: I/O and Cluster wait for LOBs

Sometimes in ADDM Report you can finding in "Top SQL Statements" following action:
  1. Action
  2. Run SQL Tuning Advisor on the INSERT statement with SQL_ID
  3. "2adh0x2quv6uh". Additionally, investigate this statement for possible
  4. performance improvements. You can supplement the information given here
  5. with an ASH report for this SQL_ID.
  6. Related Object
  7. SQL statement with SQL_ID 2adh0x2quv6uh.
  8. INSERT INTO USERINFO (SESSIONID, USERID, DICTIONARY, EXPIRES)
  9. VALUES(:1 , :2 , :3 , :4)
  10. Rationale
  11. I/O and Cluster wait for LOB "SCOTT.SYS_LOB0000155472C00008$$" with
  12. object ID 154473 consumed 60% of the database time spent on this SQL
  13. statement.
Segment Advisor recommend shrink table SESSIONINFORMATION for reclaim space, but shrinking does not work for LOBs::
  1. ALTER TABLE "SCOTT"."USERINFO" ENABLE ROW MOVEMENT
  2. ALTER TABLE "SCOTT"."USERINFO" SHRINK SPACE

Solution

Reclaiming Wasted Space:
  1. Use CASCADE option for shrink a table and all of its dependent segments (including LOB segments).

    When you specify COMPACT, Oracle Database defragments the segment space and compacts the table rows
    but postpones the resetting of the high water mark and the deallocation of the space
    until you reissue the SHRINK SPACE clause without the COMPACT clause during off-peak hours to complete
    1. ALTER TABLE SCOTT.USERINFO ENABLE ROW MOVEMENT;
    2. ALTER TABLE SCOTT.USERINFO SHRINK SPACE CASCADE COMPACT;
    3. ALTER TABLE SCOTT.USERINFO DISABLE ROW MOVEMENT;
  2. Check free unused bytes, returns information about the position of the high water mark and the amount of unused space in a segment.
    1. ALTER TABLE SCOTT.USERINFO ENABLE ROW MOVEMENT;
    2. VARIABLE total_blocks NUMBER
    3. VARIABLE total_bytes NUMBER
    4. VARIABLE unused_blocks NUMBER
    5. VARIABLE unused_bytes NUMBER
    6. VARIABLE lastextf NUMBER
    7. VARIABLE last_extb NUMBER
    8. VARIABLE lastusedblock NUMBER
    9. exec DBMS_SPACE.UNUSED_SPACE('SCOTT', 'USERINFO', 'TABLE', :total_blocks, -
    10. :total_bytes,:unused_blocks, :unused_bytes, :lastextf, -
    11. :last_extb, :lastusedblock)
    12. print
  3. Reissue the SHRINK SPACE clause without the COMPACT clause during off-peak hours to complete.
    1. ALTER TABLE SCOTT.USERINFO ENABLE ROW MOVEMENT;
    2. ALTER TABLE SCOTT.USERINFO SHRINK SPACE CASCADE;
    3. ALTER TABLE SCOTT.USERINFO DISABLE ROW MOVEMENT;
  4. Check unused bytes again, script from step 2.
  5. Issue deallocate unused space. Prior to deallocation, you can run the UNUSED_SPACE procedure, script from step 2.
    1. ALTER TABLE SCOTT.USERINFO DEALLOCATE UNUSED;
  6. Check unused bytes again, script from step 2
The LOBSEGMENT SYS_LOB0000155472C00008$$ has been reclaimed wasted space.

Resources

Oracle 10g New Features: Oracle Reclaiming Unused Space
Space, Object, and Transaction Management in Oracle Database 10g: Online Segment Shrink