<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MacLochlainns Weblog &#187; reclaiming space</title>
	<atom:link href="http://blog.mclaughlinsoftware.com/tag/reclaiming-space/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mclaughlinsoftware.com</link>
	<description>Michael McLaughlin's Technical Blog</description>
	<lastBuildDate>Mon, 06 Sep 2010 21:21:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Cleaning up wasted LOB space</title>
		<link>http://blog.mclaughlinsoftware.com/2008/04/18/cleaning-up-wasted-lob-space/</link>
		<comments>http://blog.mclaughlinsoftware.com/2008/04/18/cleaning-up-wasted-lob-space/#comments</comments>
		<pubDate>Fri, 18 Apr 2008 18:18:15 +0000</pubDate>
		<dc:creator>maclochlainn</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[blob]]></category>
		<category><![CDATA[cleaning up space]]></category>
		<category><![CDATA[cleanup clob space]]></category>
		<category><![CDATA[cleanup lob space]]></category>
		<category><![CDATA[clob]]></category>
		<category><![CDATA[dba_lobs]]></category>
		<category><![CDATA[dba_segments]]></category>
		<category><![CDATA[lob]]></category>
		<category><![CDATA[manage lobs]]></category>
		<category><![CDATA[reclaiming space]]></category>
		<category><![CDATA[saving space]]></category>
		<category><![CDATA[update lobs]]></category>

		<guid isPermaLink="false">http://maclochlainn.wordpress.com/?p=8</guid>
		<description><![CDATA[After replacing the contents of a BLOB or CLOB column, you will see the size grow because old indexes and segments aren&#8217;t deleted or removed from the index. The only way to get rid of the old information is to perform some simple table maintenance. The following provides an example of dumping redundant or obsolete [...]]]></description>
			<content:encoded><![CDATA[<p>After replacing the contents of a <code>BLOB</code> or <code>CLOB</code> column, you will see the size grow because old indexes and segments aren&#8217;t deleted or removed from the index. The only way to get rid of the old information is to perform some simple table maintenance. The following provides an example of dumping redundant or obsolete space and indexes.</p>
<p>You should first check space, by using the query provided earlier in my blog to compare LOB indexes and segments. In this test case, this is the starting point:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">COLUMN</span>                              Segment      Segment
Name  Name      Segment Name              Type           Bytes
<span style="color: #808080; font-style: italic;">----- --------- ------------------------- ---------- ---------</span>
ITEM  ITEM_BLOB SYS_IL0000074435C00007$$  LOBINDEX       <span style="color: #cc66cc;">65536</span>
ITEM  ITEM_BLOB SYS_LOB0000074435C00007$$ LOBSEGMENT   <span style="color: #cc66cc;">2097152</span>
ITEM  ITEM_DESC SYS_IL0000074435C00006$$  LOBINDEX      <span style="color: #cc66cc;">393216</span>
ITEM  ITEM_DESC SYS_LOB0000074435C00006$$ LOBSEGMENT <span style="color: #cc66cc;">226492416</span></pre></div></div>

<p>You create a temporary <code>CLOB</code> column in the target table. Then, you update the temporary column with the value from your real column.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> item <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #66cc66;">&#40;</span>item_temp CLOB<span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> item <span style="color: #993333; font-weight: bold;">SET</span> item_temp <span style="color: #66cc66;">=</span> item_desc;</pre></div></div>

<p>When you requery the table&#8217;s indexes and segments, you&#8217;d find something like the following. You should note the size of the index and segments are three times larger in the real column than the temporary columns.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">COLUMN</span>                              Segment      Segment
Name  Name      Segment Name              Type           Bytes
<span style="color: #808080; font-style: italic;">----- --------- ------------------------- ---------- ---------</span>
ITEM  ITEM_BLOB SYS_IL0000074435C00007$$  LOBINDEX       <span style="color: #cc66cc;">65536</span>
ITEM  ITEM_BLOB SYS_LOB0000074435C00007$$ LOBSEGMENT   <span style="color: #cc66cc;">2097152</span>
ITEM  ITEM_DESC SYS_IL0000074435C00006$$  LOBINDEX      <span style="color: #cc66cc;">393216</span>
ITEM  ITEM_DESC SYS_LOB0000074435C00006$$ LOBSEGMENT <span style="color: #cc66cc;">226492416</span>
ITEM  ITEM_TEMP SYS_IL0000074435C00016$$  LOBINDEX      <span style="color: #cc66cc;">131072</span>
ITEM  ITEM_TEMP SYS_LOB0000074435C00016$$ LOBSEGMENT  <span style="color: #cc66cc;">65011712</span></pre></div></div>

<p>You drop the real column and add it back. Then, you update the real column with the values from the temporary column.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> item <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> item_desc;
<span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> item <span style="color: #993333; font-weight: bold;">ADD</span> <span style="color: #66cc66;">&#40;</span>item_desc CLOB<span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">UPDATE</span> item <span style="color: #993333; font-weight: bold;">SET</span> item_desc <span style="color: #66cc66;">=</span> item_temp;</pre></div></div>

<p>You can now requery the table and find that you&#8217;ve eliminated extraneous space.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">COLUMN</span>                              Segment     Segment
Name  Name      Segment Name              Type          Bytes
<span style="color: #808080; font-style: italic;">----- --------- ------------------------- ---------- ---------</span>
ITEM  ITEM_BLOB SYS_IL0000074435C00006$$  LOBINDEX       <span style="color: #cc66cc;">65536</span>
ITEM  ITEM_BLOB SYS_LOB0000074435C00006$$ LOBSEGMENT   <span style="color: #cc66cc;">2097152</span>
ITEM  ITEM_DESC SYS_IL0000074435C00016$$  LOBINDEX      <span style="color: #cc66cc;">131072</span>
ITEM  ITEM_DESC SYS_LOB0000074435C00016$$ LOBSEGMENT  <span style="color: #cc66cc;">65011712</span>
ITEM  ITEM_TEMP SYS_IL0000074435C00016$$  LOBINDEX      <span style="color: #cc66cc;">131072</span>
ITEM  ITEM_TEMP SYS_LOB0000074435C00016$$ LOBSEGMENT  <span style="color: #cc66cc;">65011712</span></pre></div></div>

<p>You drop the temporary column after making the change.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">ALTER</span> <span style="color: #993333; font-weight: bold;">TABLE</span> item <span style="color: #993333; font-weight: bold;">DROP</span> <span style="color: #993333; font-weight: bold;">COLUMN</span> item_temp;</pre></div></div>

<p>You can now requery the table and find that you&#8217;ve eliminated extraneous space.</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #993333; font-weight: bold;">COLUMN</span>                              Segment     Segment
Name  Name      Segment Name              Type          Bytes
<span style="color: #808080; font-style: italic;">----- --------- ------------------------- ---------- ---------</span>
ITEM  ITEM_BLOB SYS_IL0000074435C00006$$  LOBINDEX       <span style="color: #cc66cc;">65536</span>
ITEM  ITEM_BLOB SYS_LOB0000074435C00006$$ LOBSEGMENT   <span style="color: #cc66cc;">2097152</span>
ITEM  ITEM_DESC SYS_IL0000074435C00016$$  LOBINDEX      <span style="color: #cc66cc;">131072</span>
ITEM  ITEM_DESC SYS_LOB0000074435C00016$$ LOBSEGMENT  <span style="color: #cc66cc;">65011712</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.mclaughlinsoftware.com/2008/04/18/cleaning-up-wasted-lob-space/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
