473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

DB2 storing CLOB strings in chunks of 1k

Customer wanted us to figure out why their database was growing at an
astronomical rate.

We broke down the various fields making up a table, and we found that the
..LB file was using about 1k per row, where the average length of the two
combined CLOB fields in the table was 12 bytes (4 bytes standard deviation).

So i hex edited the .lb file and found the problem, each clob value is
taking 0x400 bytes i.e. 1024 bytes.

So it will usually have a word or two the the user entered, followed by 1000
bytes of null.

Since the customer (censored insult here) insists that they be able to enter
comments without limit (meaning we must use a LOB field of some kind), what
field should we choose instead of CLOB so that the contents are not padded
up to be 1024 bytes long? The .LB file is only being about 1% used, and
this is just nasty. As it stands, the database is growing about 60% faster
than the data it holds.

Perhaps using NTFS file compression to shut them up?

This is only a problem because the customer is demanding to know where all
the extra space is going - and right now the answer is: DB2 is padding 6
bytes to take up 1024.

Keywords: db2 storing clobs multiple 1024 1k 0x400 bytes chunk lb file slack
space database size growing lb
Feb 23 '07 #1
7 5117
On Feb 23, 9:34 am, "Ian Boyd" <ian.msnews...@avatopia.comwrote:
Customer wanted us to figure out why their database was growing at an
astronomical rate.

We broke down the various fields making up a table, and we found that the
.LB file was using about 1k per row, where the average length of the two
combined CLOB fields in the table was 12 bytes (4 bytes standard deviation).

So i hex edited the .lb file and found the problem, each clob value is
taking 0x400 bytes i.e. 1024 bytes.

So it will usually have a word or two the the user entered, followed by 1000
bytes of null.

Since the customer (censored insult here) insists that they be able to enter
comments without limit (meaning we must use a LOB field of some kind), what
field should we choose instead of CLOB so that the contents are not padded
up to be 1024 bytes long? The .LB file is only being about 1% used, and
this is just nasty. As it stands, the database is growing about 60% faster
than the data it holds.

Perhaps using NTFS file compression to shut them up?

This is only a problem because the customer is demanding to know where all
the extra space is going - and right now the answer is: DB2 is padding 6
bytes to take up 1024.

Keywords: db2 storing clobs multiple 1024 1k 0x400 bytes chunk lb file slack
space database size growing lb
Did you try the "COMPACT" option on the LOB column? I don't know how
much space it will save, but you could try it.

Feb 23 '07 #2
On Fri, 23 Feb 2007 11:34:00 -0500, "Ian Boyd"
<ia***********@avatopia.comwrote:
>Customer wanted us to figure out why their database was growing at an
astronomical rate.

We broke down the various fields making up a table, and we found that the
.LB file was using about 1k per row, where the average length of the two
combined CLOB fields in the table was 12 bytes (4 bytes standard deviation).

So i hex edited the .lb file and found the problem, each clob value is
taking 0x400 bytes i.e. 1024 bytes.

So it will usually have a word or two the the user entered, followed by 1000
bytes of null.

Since the customer (censored insult here) insists that they be able to enter
comments without limit (meaning we must use a LOB field of some kind),
Actually, that is untrue. LOBs do have limits. Unlikely to ever hit
them, but... :)

Instead, CREATE a separate TABLE for comments.

CREATE TABLE Item_Comments
{
Id AUTONUMBER
Item INT REFERENCES ...
Comment VARCHAR(32000)
}

And just chop comments on their way in.

Or...

Use a VARCHAR in the main TABLE to hold comments up to 255 characters,
or the like. And, CREATE a comment TABLE to hold CLOBs.

CREATE TABLE Item_Comments
{
Item INT REFERENCES ...
Comment CLOB
}

Have a TRIGGER check ON INSERT if the value for the comment is more
than 255 characters, and if so, INSERT a NULL instead, and INSERT the
comment INTO the Comments TABLE instead.

Oh, and put LOB in their own TABLESPACE. Just easier for management.

B.
what
field should we choose instead of CLOB so that the contents are not padded
up to be 1024 bytes long? The .LB file is only being about 1% used, and
this is just nasty. As it stands, the database is growing about 60% faster
than the data it holds.

Perhaps using NTFS file compression to shut them up?

This is only a problem because the customer is demanding to know where all
the extra space is going - and right now the answer is: DB2 is padding 6
bytes to take up 1024.

Keywords: db2 storing clobs multiple 1024 1k 0x400 bytes chunk lb file slack
space database size growing lb
Feb 26 '07 #3
Actually, that is untrue. LOBs do have limits. Unlikely to ever hit
them, but... :)
As far as i'm concerned character(8000) would be a limit they'll never hit
either; but you can't explain that to the hoopleheads.
Instead, CREATE a separate TABLE for comments.

CREATE TABLE Item_Comments
{
Id AUTONUMBER
Item INT REFERENCES ...
Comment VARCHAR(32000)
}

And just chop comments on their way in.

Or...

Use a VARCHAR in the main TABLE to hold comments up to 255 characters,
or the like. And, CREATE a comment TABLE to hold CLOBs.

CREATE TABLE Item_Comments
{
Item INT REFERENCES ...
Comment CLOB
}

Have a TRIGGER check ON INSERT if the value for the comment is more
than 255 characters, and if so, INSERT a NULL instead, and INSERT the
comment INTO the Comments TABLE instead.

Oh, and put LOB in their own TABLESPACE. Just easier for management.


That would be an okay idea, except that it would require a rewrite of a
large amount of things. And since we also had our hands tied into using
Hibernate; it makes it even more of a mess.

If DB2 is unable to store CLOB text efficiently, then i'd rather tell them:
"It's a DB2 thing, because you wanted to be able to enter text without
limit. So either be happy with 4000 characters, or buy a bigger hard drive."

Feb 26 '07 #4
>So i hex edited the .lb file and found the problem, each clob value is
>taking 0x400 bytes i.e. 1024 bytes.
Did you try the "COMPACT" option on the LOB column? I don't know how
much space it will save, but you could try it.
Tried it, it doesn't save any space. DB2 still pads clob values to take up
0x400 bytes.

Reading the docs on COMPACT, after you mentioned it, i would have thought it
is exactly what we were after.
Feb 26 '07 #5
On Mon, 26 Feb 2007 10:30:02 -0500, "Ian Boyd"
<ia***********@avatopia.comwrote:
>Actually, that is untrue. LOBs do have limits. Unlikely to ever hit
them, but... :)

As far as i'm concerned character(8000) would be a limit they'll never hit
either; but you can't explain that to the hoopleheads.
>Instead, CREATE a separate TABLE for comments.

CREATE TABLE Item_Comments
{
Id AUTONUMBER
Item INT REFERENCES ...
Comment VARCHAR(32000)
}

And just chop comments on their way in.

Or...

Use a VARCHAR in the main TABLE to hold comments up to 255 characters,
or the like. And, CREATE a comment TABLE to hold CLOBs.

CREATE TABLE Item_Comments
{
Item INT REFERENCES ...
Comment CLOB
}

Have a TRIGGER check ON INSERT if the value for the comment is more
than 255 characters, and if so, INSERT a NULL instead, and INSERT the
comment INTO the Comments TABLE instead.

Oh, and put LOB in their own TABLESPACE. Just easier for management.

That would be an okay idea, except that it would require a rewrite of a
large amount of things. And since we also had our hands tied into using
Hibernate; it makes it even more of a mess.
Is it possible you could use a VIEW instead? Because the first option
i mentioned should work very well with a VIEW.
>If DB2 is unable to store CLOB text efficiently, then i'd rather tell them:
"It's a DB2 thing, because you wanted to be able to enter text without
limit. So either be happy with 4000 characters, or buy a bigger hard drive."
I wonder if we could make idrathertellthem.com

Oh my, http://whatireallywanttosay.com/ is an actual link. /me cries.

B.
Feb 26 '07 #6
Is it possible you could use a VIEW instead? Because the first option
i mentioned should work very well with a VIEW.
Trying such things as having data in a view and a table is a nightmare to
deal with using Hibernate.
The customer's original inquiry was, "What's taking up all the database
space?"

My own (internal) response was, "i dunno, ask DB2. We're not going to start
debugging DB2 internal data structures."

Now i can say to the customer "It's how DB2 stores notes."
Feb 26 '07 #7
On Mon, 26 Feb 2007 16:58:32 -0500, "Ian Boyd"
<ia***********@avatopia.comwrote:
>Is it possible you could use a VIEW instead? Because the first option
i mentioned should work very well with a VIEW.

Trying such things as having data in a view and a table is a nightmare to
deal with using Hibernate.
I have no idea what Hibernate is, so i'll just have to trust you on
this one.

B.
>The customer's original inquiry was, "What's taking up all the database
space?"

My own (internal) response was, "i dunno, ask DB2. We're not going to start
debugging DB2 internal data structures."

Now i can say to the customer "It's how DB2 stores notes."
Feb 27 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: freak | last post by:
hi i have problems reading an oracle(9i) clob from a php-script with the MDB-class from pear. the table files has 3 fields: id integer document clob picture clob
1
by: Chris | last post by:
I use websphere connection pooling and had a failure attempting a CLOB.createTemporary. tempClob = CLOB.createTemporary(conn, true, CLOB.DURATION_SESSION); Here's an excerpt of the exception...
5
by: gimme_this_gimme_that | last post by:
In Oracle you can have a statement such as insert into foo (foo_id,some_clob) values (100,empty_clob()) where empty_clob() inserts a clob address. What is the approach in DB2 (8.1) to...
3
by: gupta.harika | last post by:
Hi everyone, I am a developer working on php with oracle as backend. I am facing a problem related with the CLOB data. The problem is as follows My application uses a table which contains Clob...
8
by: gimme_this_gimme_that | last post by:
I have the following Java code : package com.rhi.bb.udf.utils; import java.sql.Clob; import java.sql.SQLException; import java.util.regex.Pattern; import java.util.regex.Matcher;
2
BSOB
by: BSOB | last post by:
I am just wondering about how practical it is to use the registry to store settings. I have several boolean values that are currently being stored in the regestry for my application and a seperate...
0
by: *Davide* | last post by:
Hello, This query (PHP+Oracle) works: global $user,$pass,$sid; $db_charset = 'UTF8'; $db = OCILogon($user, $pass, $sid, $db_charset); $clob = OCINewDescriptor($db, OCI_D_LOB); $txt_clob =...
0
by: srinivasaraonagisetty | last post by:
hi, I am faceing one problem, while inserting the data in db2 using clob. actually i am writing this type code: public class DBParam { private InputStream inputstream; private static int...
1
by: Veeru71 | last post by:
When I am SELECT'ing a CLOB column from command prompt, the output is getting truncated after a certail limit (8 K ??) How do I get the full data out of a CLOB column? Are there any string...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.