Oracle Temp Extent Map Analyzer

Displays temporary extents and their block locations inside the temporary tablespace to help identify fragmentation and gaps. Useful for TEMP tablespace analysis and troubleshooting space allocation issues.

oraclesqlbackup-restorev1.0.0
0 stars0 downloads15 views0 comments
By OracleDba • Created

Code

(43 lines)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
-- -----------------------------------------------------------------------------------
-- File Name    : http://www.oracle-base.com/dba/monitoring/temp_extent_map.sql
-- Author       : DR Timothy S Hall
-- Description  : Displays temp extents and their locations within the tablespace allowing identification of tablespace fragmentation.
-- Requirements : Access to the DBA views.
-- Call Syntax  : @temp_extent_map (tablespace-name)
-- Last Modified: 25/01/2003
-- -----------------------------------------------------------------------------------
SET SERVEROUTPUT ON SIZE 1000000
SET FEEDBACK OFF
SET TRIMOUT ON
SET VERIFY OFF

DECLARE
  CURSOR c_extents IS
    SELECT d.name,
           t.block_id AS start_block,
           t.block_id + t.blocks - 1 AS end_block
    FROM   v$temp_extent_map t,
           v$tempfile d
    WHERE  t.file_id = d.file#
    AND    t.tablespace_name = Upper('&1')
    ORDER BY d.name, t.block_id;
    
  l_last_block_id  NUMBER  := 0;
  l_gaps_only      BOOLEAN := TRUE;
BEGIN
  FOR cur_rec IN c_extents LOOP
    IF cur_rec.start_block > l_last_block_id + 1 THEN
      DBMS_OUTPUT.PUT_LINE('*** GAP *** (' || l_last_block_id || ' -> ' || cur_rec.start_block || ')');
    END IF;
    l_last_block_id := cur_rec.end_block;
    IF NOT l_gaps_only THEN
      DBMS_OUTPUT.PUT_LINE(RPAD(cur_rec.name, 50, ' ') || 
                           ' (' || cur_rec.start_block || ' -> ' || cur_rec.end_block || ')');
    END IF;
  END LOOP;
END;
/

PROMPT
SET FEEDBACK ON
SET PAGESIZE 18

General Comments(0)

Tip: Click on a line number in the code to add a line-specific comment

No general comments yet. Be the first to comment!