Skip to Main Content
  • Questions
  • performance impact of CLOB's in table

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Vishal.

Asked: August 19, 2017 - 4:16 am UTC

Last updated: August 23, 2017 - 7:17 am UTC

Version: 12c

Viewed 10K+ times! This question is

You Asked

Hi,

If I create a table of 20 columns and 2 of them are clob datatype. It seems that selection from that table is very slow even I am not selecting the clob data. Is it possible. Any example to check this.

and Connor said...

There are two kinds of storage for CLOB's

1) in row

The clob is stored like any other column in the row. This can only be done for clob up to a certain size (approx 4k). Clobs larger than this will stored in a separate segment (the "lobsegment")

2) out of row

The clob is always stored out of the row in the lobsegment

You can which is being used for your table by checking USER_LOBS.

It is possible, particularly in the first 'in row' instance that your table consume more blocks for the "normal" rows because of the interspersed lob data, and hence takes longer to scan. But we'd need to see some more concrete figures defining what you mean by "selection from that table is very slow"

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

Vishal, August 20, 2017 - 3:53 am UTC

Mine is in row. Slow mean, reading data from the table is slow even i m not selecting the clob columns.
Connor McDonald
August 21, 2017 - 5:21 am UTC

What you are *selecting* isn't as important as what you are *scanning*.

If I have to walk to the shop to get an apple, then if the shop is 10meters away, I'll do it quickly. If that shop is 10miles away, it will take a long time, even though in both cases I'm just getting an apple.

If you are scanning a table that has the clob data interspersed throughout the rows, then isolating rows/columns that match your query predicates *still* has navigate through that clob data even if you are not selecting the clob column.


so?

A reader, August 21, 2017 - 5:53 am UTC

What your advice about? In row or out of row (in this case )
What is both inconvenience ? You could use *it depend * thank you.
Connor McDonald
August 23, 2017 - 7:17 am UTC

There are typically two common uses for LOBS.

1) "Small-ish" data, eg XML fragments, descriptions, etc etc. They are *mostly* 1000-4000 chars, but occasionally exceed that. So really you want something is like a "slightly bigger varchar2". For this an inline clob makes sense because you're treating the majority of the data like a varchar2, but catering for the occasional large ones. Forcing them out of line is going to cost you in terms of access (to the lob) because you'll be walking through a lob indexing structure to get content. Conversely, the raw table data is now a little slower to scan through because the LOB data is interspersed there.

2) Large data, eg, you are storing entire documents, or PDF files, or images and videos etc. In this case, just about every LOB is going to be tens of kilobytes, or megabytes in size. So now its the opposite of above - you *know* that any LOB access will be walking through the lob index structure anyway (because its such a large LOB) so you may as well keep it out of the row "entirely".

But dont forget...there are exceptions to *every* rule. Let's say your lobs are small *but* your application almost *never* accesses the lob - they are there for (say) annotative purposes. In that case, you might opt to have them out of line because they are so rarely accessed.

More to Explore

Administration

Need more information on Administration? Check out the Administrators guide for the Oracle Database