Skip to content
Keep Learning Keep Living
Keep Learning Keep Living
Keep Learning Keep Living

CLOB size matters!

Mustafa, 2019-07-312020-07-05

Hi,

Many developer and DBA has an idea about the storing clobs. Basic rule is “if length of clob is higher tan 4000 then it will be stored in lob segment not in table segment” which is correct but sometimes misinterpreted!

if you have a clob column in your table, your data might be in the table. since LOBs(large objects) can be too big Oracle stores them in a separate segment. this is very important because while you are selecting your table, you might be reading not just your table also lob segment which will decrease your performance of course. as tuning step Oracle stores your clob data in the table segment if length of lob is less than 4000. This means Oracle act to your data as varchar2 which will be faster but as I said this is causing a misunderstanding.

So you check your clob data and all of them has 4000 bytes length unfortunately all of those data are in the lob segment not in the table! why? because of the large object overhead! every large object has some header information and this is the part of that magical number “4000”. Because of that your data must be less than 4000 and the new magical number is 3964. your data must be equal or less than 3964 to be stored in the table segment.

here is the proof:

Oracle PL/SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
create table tmp_lob (mydata clob);
 
insert into tmp_lob
  select lpad('1', 4000, '1')
  from dual
  connect by level <= 10000;
commit;
 
select bytes/1024 size_in_KB
from   user_segments
where  segment_name ='TMP_LOB';
--------------------------------------
--576
 
select bytes/1024 size_in_KB
from   user_segments
where  segment_name = (select l.segment_name from dba_lobs l where table_name = 'TMP_LOB');
-----------------------------------
--98496

I just create a table with a clob column and inserted 10.000 rows with 4000 length of clob data. when we check the user_segments for our table we will simply see that it has 576KB which is really small. After that checking LOB segment size, we are able to see the truth! our lob segment size is 98496KB. so all of our data has been stored in lob segment!

Let’s run the same code for 3964 byte characters:

Oracle PL/SQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
truncate table tmp_lob;
 
insert into tmp_lob
  select lpad('1', 3964, '1')
  from dual
  connect by level <= 10000;
commit;
 
select bytes/1024 size_in_KB
from   user_segments
where  segment_name ='TMP_LOB';
-------------------------------
--81920
 
select bytes/1024 size_in_KB
from   user_segments
where  segment_name = (select l.segment_name from dba_lobs l where table_name = 'TMP_LOB');
-------------------------------
--128

Here it is. with 3964 bytes clob data, our table size is 81920KB and lob segment size is 128KB. Simply all the data is stored in the table not in the lob segment.

Is there a misdirection on documentation about this 4000 size? NO! Oracle says, Large objects will be stored in the table segments if their size is less than 4000 but this size is not the size of our data. this size includes the LOB overhead.

have a nice day.

11g 12c 18c 19c Administration Development CLOBclob segmentclob sizeinline cloboutline clobsize

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • DDL Generation Failed with ORA-65047: Object SYS.KUPUTIL is invalid
  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval

Recent Comments

  • Mustafa on How to call HTTPS Url Without SSL Wallet in 19c
  • Накрутка авито on How to call HTTPS Url Without SSL Wallet in 19c
  • Mustafa on Cloud Base Database Service
  • Raja on Cloud Base Database Service
  • Mustafa on Refreshable PDB and ORA-17627: ORA-12578: TNS:wallet open failed

Categories

  • 11g
  • 12c
  • 18c
  • 19c
  • 21c
  • 23ai
  • Administration
  • Cloud
  • Compression
  • Development
  • Materialized View
  • Multi-tenant
  • Performance
  • Security
  • SQL / PLSQL
  • Uncategorized
  • Undocumented
  • Useful Scripts

Archives

  • June 2025
  • April 2025
  • November 2024
  • July 2024
  • April 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • June 2018

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

RSS Follow This Blog

  • DDL Generation Failed with ORA-65047: Object SYS.KUPUTIL is invalid
  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval
  • How to Copy Local Files to Oracle Object Storage
  • Guid vs Sequences

Archives

  • June 2025
  • April 2025
  • November 2024
  • July 2024
  • April 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • October 2021
  • September 2021
  • August 2021
  • April 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • July 2019
  • June 2019
  • May 2019
  • March 2019
  • February 2019
  • June 2018

RSS Follow This Blog

  • DDL Generation Failed with ORA-65047: Object SYS.KUPUTIL is invalid
  • How to call HTTPS Url Without SSL Wallet in 19c
  • Is Table Unnecessary for Pipelined Function
  • Password Rollover Time in Seconds
  • PDB Syncronization Issue
  • How to limit DB Link Connection Timeout
  • Cloud Base Database Service
  • 29th of February and interval
  • How to Copy Local Files to Oracle Object Storage
  • Guid vs Sequences
RSS Error: A feed could not be found at `http://www.mywebsite.com/feed/`; the status code is `200` and content-type is `text/html; charset=UTF-8`
©2025 Keep Learning Keep Living | WordPress Theme by SuperbThemes