-- UNDO tablespace current usage / available space
SELECT a.TABLESPACE_NAME, SIZEMB, USAGEMB, (SIZEMB - USAGEMB) AS FREEMB
FROM (SELECT round(sum(BYTES) / 1e6) AS SIZEMB, b.TABLESPACE_NAME
FROM DBA_DATA_FILES a, DBA_TABLESPACES b
WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME AND b.CONTENTS LIKE '%UNDO%'
GROUP BY b.TABLESPACE_NAME) a,
(SELECT c.TABLESPACE_NAME, sum(BYTES) / 1e6 AS USAGEMB
FROM DBA_UNDO_EXTENTS c
WHERE STATUS <> 'EXPIRED'
GROUP BY c.TABLESPACE_NAME) b
WHERE a.TABLESPACE_NAME = b.TABLESPACE_NAME;
-- UNDO tablespace usage per user / session
SELECT s.SID, s.USERNAME, round(sum(ss.VALUE) / 1e6, 2) AS UNDO_SIZE_MB,
sql.ELAPSED_TIME, sql.SQL_TEXT
FROM V$SESSTAT ss JOIN V$SESSION s ON s.SID = ss.SID
JOIN V$STATNAME STAT ON STAT.STATISTIC# = ss.STATISTIC#
LEFT JOIN V$SQLAREA sql
ON s.SQL_ADDRESS = sql.ADDRESS AND s.SQL_HASH_VALUE = sql.HASH_VALUE
WHERE STAT.NAME = 'undo change vector size' AND s.TYPE <> 'BACKGROUND'
AND s.USERNAME IS NOT NULL AND ss.VALUE >= 0.01 * 1e6
GROUP BY s.SID, s.USERNAME, sql.ELAPSED_TIME, sql.SQL_TEXT
ORDER BY s.USERNAME, round(sum(ss.VALUE) / 1e6, 2);
-- UNDOTBS usage per User:
SELECT u.TABLESPACE_NAME AS TABLESPACE,
s.USERNAME,
u.STATUS,
sum(u.BYTES) / 1024 / 1024 AS SUM_IN_MB,
count(u.SEGMENT_NAME) AS SEG_CNTS
FROM DBA_UNDO_EXTENTS u, V$TRANSACTION T, V$SESSION s
WHERE T.ADDR = s.TADDR
GROUP BY u.TABLESPACE_NAME, s.USERNAME, u.STATUS
ORDER BY 1, 2, 3;
Code Example |
---|
Sql :: sql insert into select statement |
Sql :: mysql inner join |
Sql :: mysql remove tabs from string |
Sql :: sql order by except one row |
Sql :: postgres insert timestamp without timezone |
Sql :: 0 |
Sql :: postgresql like |
Sql :: acual month sql |
Sql :: mysql shell |
Sql :: sql asc |
Sql :: mysql create view |
Sql :: drop procedure postgres |
Sql :: postgresql show tables |
Sql :: sql default |
Sql :: creashed table mysql |
Sql :: oracle cache matching |
Sql :: connectionString |
Sql :: sqlalchemy orm duplicate |
Sql :: join three tables sql |
Sql :: psql query execution time |
Sql :: import mysql db |
Sql :: how to find 2nd highest salary in mysql |
Sql :: sql server function to calculate a percentage |
Sql :: sql is not null |
Sql :: les jointures sql server |
Sql :: triggers db |
Sql :: select limit ms sql |
Sql :: join vs union |
Sql :: TITLE: SQL Server principal "dbo" does not exist |
Sql :: sql int vs integer |