LOBs (Large Objects) are often the silent space hogs in Oracle databases — especially when poorly managed or not regularly reorganized. In this post, I’ll walk you through how I reduced a massive in a real Oracle production environment using simple and efficient techniques — no downtime, no data loss.

The Challenge

A LOB column (C49733) in the table dbadeeds.EMP had ballooned to over 4.2 TB:

SELECT SEGMENT_NAME, TABLESPACE_NAME, BYTES/1024/1024/1024 GB
FROM DBA_SEGMENTS
WHERE SEGMENT_NAME LIKE 'SYS_LOB0000323358C00012$$'
AND OWNER = 'DBADEEDS';

Result:

Segment NameTablespaceSize (GB)
SYS_LOB0000323358C00012$$DEEDS_TBS4296.25

Step 1: Identify the LOB Segment

We queried metadata to pinpoint the exact LOB segment associated with the column:

sqlCopyEditSELECT l.owner, l.table_name, l.column_name, l.segment_name, 
       l.tablespace_name, ROUND(s.bytes/1024/1024/1024, 1) size_Gb
FROM   dba_lobs l
JOIN   dba_segments s ON s.owner = l.owner AND s.segment_name = l.segment_name
WHERE  s.segment_name LIKE 'SYS_LOB0000323358C00012$$'
ORDER  BY 6 DESC;

Step 2: Create a Temporary Tablespace

To reorganize the LOB data, I created a temporary staging tablespace:

CREATE BIGFILE TABLESPACE DEEDS_TBS_TMP 
DATAFILE SIZE 50G
AUTOEXTEND ON NEXT 1G
MAXSIZE 4500G;

Step 3: Move the LOB Column to the New Tablespace

Now for the magic: move the table and LOB column online using parallel DML.

ALTER TABLE DBADEEDS.EMP 
MOVE TABLESPACE DEEDS_TBS_TMP
LOB (C49733)
STORE AS (TABLESPACE DEEDS_TBS_TMP)
ONLINE PARALLEL 16;

After the move, we checked the segment size:

SELECT SEGMENT_NAME, TABLESPACE_NAME, BYTES/1024/1024/1024 GB 
FROM DBA_SEGMENTS
WHERE SEGMENT_NAME LIKE 'SYS_LOB0000323358C00012$$'
AND OWNER = 'DBADEEDS';

Result:

Segment NameTablespaceSize (GB)
SYS_LOB0000323358C00012$$DEEDS_TBS_TMP4.0

✅ LOB segment successfully compacted!


Step 4: Move LOB Back to Original Tablespace

To maintain storage policy consistency, I moved the LOB back to its original tablespace:

ALTER TABLE DBADEEDS.EMP 
  MOVE TABLESPACE DEEDS_TBS 
  LOB (C49733) 
  STORE AS (TABLESPACE DEEDS_TBS) 
  ONLINE PARALLEL 16;

Final size remained 4 GB — confirming that the reorganization worked perfectly.

Step 5: Clean Up

Since the temporary tablespace is no longer needed:

sqlCopyEditDROP TABLESPACE DEEDS_TBS_TMP INCLUDING CONTENTS AND DATAFILES;

✅ Done. LOB segment is compacted and returned to its original location with minimal effort.


  • 🔻 Space savings: From 4.2 TB → 4 GB
  • 🧠 No data loss: Entire operation done online
  • Minimal impact: Thanks to PARALLEL and ONLINE clauses
  • 💰 Reduced storage cost and improved backup speed

LOB segments tend to grow significantly over time due to fragmentation and retention. By leveraging LOB segment reorganization — especially with online move and temporary tablespace staging — you can dramatically reduce space and optimize performance with minimal downtime.

Don’t let your LOBs run wild!

7 responses to “How I Shrink Reduced LOB Segments in Oracle Database”

  1. Appu Avatar
    Appu

    Hi,

    How much time it took for you to complete this LOB shrink. For us it is still executing from the last 24 hours and LOB size is around 2.5TB, we are using parallel 12 and ONLINE clause.

    Regards,

    Appu

    Like

    1. DBADEEDS Avatar

      I took 8 hrs for us to complete.
      Btw check if that table is locked by any active session. It shouldn’t take this long if you are using parallel 12

      Like

  2. Appu Avatar
    Appu

    Hello,

    Thank for your quick response, we are doing this practice on duplicate database that is idle in nature, I have verified and there were no locks on that table.

    Any other suggestion’s.

    Regards,

    Appu.

    Like

  3. Appu Avatar
    Appu

    Hi,The moment we started LOB shrink, the lock held on that particular table. Should we clear that.Below is snippet for your reference.OBJECT_TYPE SESSION_ID TY LMODE REQUEST BLOCK CTIME

    TABLE 3798 TM 6 0 0 146419 OSUSER STATUS SQL_ID

    oracle ACTIVE 8p97tdtg7vnm9select SQL_FULLTEXT from v$sql where sql_id=’8p97tdtg7vnm9′; SQL_FULLTEXT

    ALTER TABLE schema.table_name MOVE LOB( ML_DATA)STORE AS (TABLESPACE DATA_REORG_LOB) parallel 12Note : This lock is related to ongoing activity.Please suggest…Regards,

    Appu.

    Like

    1. DBADEEDS Avatar

      We have done this exercise during non business our so we didn’t see this any active sessions on this table.

      Like

  4. Appu Avatar
    Appu

    Hi Bro,

    May i know your gmail ID ?

    Like

  5. Appu Avatar
    Appu

    Hi,

    As i mentioned earlier, we are doing this on duplicate database(exact replica of PROD). As it is a duplicate database there are no app/active sessions in it.

    Regards,

    Appu.

    Like

Leave a comment