<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.5" -->
<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/"
	>

<channel>
	<title>Open Closure</title>
	<link>http://www.openclosure.org</link>
	<description></description>
	<pubDate>Wed, 06 Aug 2008 20:55:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<item>
		<title>Oracle Partitioned Indexes - Part 1 (identifying the need)</title>
		<link>http://www.openclosure.org/2008/08/05/oracle-partitioned-indexes-part-1-identifying-the-need/</link>
		<comments>http://www.openclosure.org/2008/08/05/oracle-partitioned-indexes-part-1-identifying-the-need/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 04:46:40 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
		
	<category>Oracle</category>
		<guid isPermaLink="false">http://www.openclosure.org/2008/08/05/oracle-partitioned-indexes-part-1-identifying-the-need/</guid>
		<description><![CDATA[There&#8217;s a company I work with (read, &#8220;for&#8221;) that seems to be having a bit of trouble getting 4M rows into a table.  Typically this isn&#8217;t an issue, but the nature of the data, suggests Oracle support, is causing the index to be &#8220;unbalanced.&#8221;  There&#8217;s a more technical term for the lack of [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a company I work with (read, &#8220;for&#8221;) that seems to be having a bit of trouble getting 4M rows into a table.  Typically this isn&#8217;t an issue, but the nature of the data, suggests Oracle support, is causing the index to be &#8220;unbalanced.&#8221;  There&#8217;s a more technical term for the lack of balancing, and though I was scolded for using the term lopsided (Thanks, Tom), I still imagine the b-tree visually being lopsided.  In any case, all of the signs point to the primary key as the issue.  I&#8217;m dealing with a two column table, both of type &#8220;NUMBER&#8221; and both are used for the Primary Key.  There&#8217;s about 500,000,000 rows in the table and I&#8217;m trying to add 4,000,000 rows.  When diving in to <a href="http://blog.tanelpoder.com/2008/06/06/advanced-oracle-troubleshooting-guide-part-5-sampling-v-stuff-with-waitprof-really-fast-using-sql/">super secret Oracle internals</a>, I&#8217;ve found that almost all of the waits are of type &#8220;db file scattered read&#8221; and when run with the &#8220;e1&#8243; parameter, the data file it&#8217;s after only houses one part of this table: the index which is the primary key.  Interesting to say the least.</p>
<p>At this point, Oracle isn&#8217;t much help and things are getting worse, so I&#8217;ve decided if index maintenance is the issue, there&#8217;s gotta be a better way to store the index information.  Maybe partitioning the table with a hash partition and locally partitioned indexes&#8230; then the answer comes to me in the form of Oracle&#8217;s own documentation.</p>
<p>Globally partitioned indexes.  Just like partitioned tables, a database can have partitioned indexes, local OR global.  Locally partitioned indexes require a partitioned table and, from what I can tell, the same partitioning parameters, whereas globally partitioned indexes can be on anything, even when on a partitioned table&#8230;. sounds messy.</p>
<p>Next up&#8230; Oracle Partitioned Indexes - Part 2 (choosing the partition type)
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.openclosure.org/2008/08/05/oracle-partitioned-indexes-part-1-identifying-the-need/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>PHP OCI8 Driver Update</title>
		<link>http://www.openclosure.org/2007/10/19/php-oci8-driver-update/</link>
		<comments>http://www.openclosure.org/2007/10/19/php-oci8-driver-update/#comments</comments>
		<pubDate>Sat, 20 Oct 2007 05:25:57 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
		
	<category>PHP</category>
	<category>Oracle</category>
		<guid isPermaLink="false">http://www.openclosure.org/2007/10/19/php-oci8-driver-update/</guid>
		<description><![CDATA[I got a call from Chris Jones over at Oracle about some really cool news.  Oracle 11g&#8217;s support for Database Resident Connection Pooling (pdf) is now supported in the beta version of PHP&#8217;s OCI8 Driver.  Chris and I had a long conversation a couple weeks back about where the responsibility for the driver [...]]]></description>
			<content:encoded><![CDATA[<p>I got a call from Chris Jones over at Oracle about some <a target="_blank" href="http://blogs.oracle.com/opal/2007/10/09">really cool news</a>.  Oracle 11g&#8217;s support for <a target="_blank" href="http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf">Database Resident Connection Pooling</a> (pdf) is now supported in the beta version of PHP&#8217;s <a target="_blank" href="http://pecl.php.net/package/oci8">OCI8 Driver</a>.  Chris and I had a long conversation a couple weeks back about where the responsibility for the driver should end, and where it should begin which sparked a few interesting topics like result set caching (also available in 11g).  The net of all of this are two pretty cool features in the new driver: Support for 11g&#8217;s connection pooling and support for Fast Application Notification (FAN).  Due to our platform (Solaris vs. Linux) we don&#8217;t get the joyous opportunity to try out the DRCP support; however, we&#8217;re extremely excited to be beta testing 1.3.0 of the driver specifically for FAN support.</p>
<p>I&#8217;m not a DBA, and even though I pretend sometimes, I can&#8217;t even come close to pretending on this one.  We have a primary database and a secondary database (physical standby) using DataGuard.  With FAN support, we can actually fail over to the secondary database, and allow the OCI8 driver to avoid the giant timeout normally found in TCP, reconnect and pick up where it left off.  I&#8217;m super excited to see this working&#8230; has anyone tried it yet?
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.openclosure.org/2007/10/19/php-oci8-driver-update/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Oracle WITH clause</title>
		<link>http://www.openclosure.org/2007/10/18/oracle-with-clause/</link>
		<comments>http://www.openclosure.org/2007/10/18/oracle-with-clause/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 04:35:25 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
		
	<category>Oracle</category>
		<guid isPermaLink="false">http://www.openclosure.org/2007/10/18/oracle-with-clause/</guid>
		<description><![CDATA[This is one of the coolest things ever.  One of our wonderfully spectacular DBAs (Hi, Brian!) pointed this out and it has saved us a couple times.  I know there are better ways to implement this specific example, but it&#8217;s to illustrate a point.  Here&#8217;s what we do now:
CREATE TABLE temp_1 (
user_id [...]]]></description>
			<content:encoded><![CDATA[<p>This is one of the coolest things ever.  One of our wonderfully spectacular DBAs (Hi, Brian!) pointed this out and it has saved us a couple times.  I know there are better ways to implement this specific example, but it&#8217;s to illustrate a point.  Here&#8217;s what we do now:</p>
<p>CREATE TABLE temp_1 (<br />
user_id NUMBER(3)<br />
);<br />
INSERT INTO temp_1<br />
(user_id)<br />
SELECT user_id<br />
FROM table1;</p>
<p>SELECT user_name, user_info<br />
FROM users, temp_1<br />
WHERE users.user_id=temp_1.user_id;</p>
<p>And here&#8217;s using the WITH clause:</p>
<p>WITH temp_1 AS (<br />
SELECT user_id<br />
FROM table1<br />
)<br />
SELECT user_name, user_info<br />
FROM users, temp_1<br />
WHERE users.user_id = temp_1.user_id</p>
<p>Oracle creates a temporary table internally and uses it in the query.  You might be thinking, &#8220;not a big deal, I do things like this all the time.&#8221;  Here&#8217;s the kicker: There&#8217;s NO redo generated.  For those of use with physical and/or logical standby&#8217;s, we NEED this kind of functionality to keep redo down on the backup databases.  YAY!
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.openclosure.org/2007/10/18/oracle-with-clause/feed/</wfw:commentRSS>
		</item>
		<item>
		<title>Hierarchical Data Sets</title>
		<link>http://www.openclosure.org/2007/10/15/hierarchical-data-sets/</link>
		<comments>http://www.openclosure.org/2007/10/15/hierarchical-data-sets/#comments</comments>
		<pubDate>Tue, 16 Oct 2007 04:19:50 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
		
	<category>Oracle</category>
		<guid isPermaLink="false">http://www.openclosure.org/2007/10/15/hierarchical-data-sets/</guid>
		<description><![CDATA[Matthew Turland wrote on his blog, &#8220;[the nested set] model is simple and intuitive, but it has a drawback: to obtain any significant portion of the hierarchy stored in a table can take up to as many queries as there are levels of depth in the hierarchy.&#8221;  I like the theory that Matthew talks [...]]]></description>
			<content:encoded><![CDATA[<p>Matthew Turland wrote on <a target="_blank" href="http://ishouldbecoding.com/2007/09/16/supporting-hierarchical-data-sets/">his blog</a>, &#8220;[the nested set] model is simple and intuitive, but it has a drawback: to obtain any significant portion of the hierarchy stored in a table can take up to as many queries as there are levels of depth in the hierarchy.&#8221;  I like the theory that Matthew talks about and the <a target="_blank" href="http://www.developer.com/db/article.php/3517366">implementation for Oracle</a> provided by developer.com got me thinking.  I wasn&#8217;t so sure that some of the analytic functions in Oracle couldn&#8217;t make this happen faster/better/cheaper, so I set out to figure it out.</p>
<p>One of the primary concerns with the nested set model is the requirement that N number of rows would have to be updated with each new item.  This is a deal-breaker in my job and wouldn&#8217;t fly, so I&#8217;ve added an additional column to assist in the solution that identifies the level at which the item occurs.</p>
<p>Given the following data set:</p>
<table width="300" border="1">
<tr>
<th bgcolor="#c0c0c0" align="left">ID</th>
<th bgcolor="#c0c0c0" align="left">PARENT_ID</th>
<th bgcolor="#c0c0c0" align="left">SITE_AREA</th>
<th bgcolor="#c0c0c0" align="left">SITE_LEVEL</th>
</tr>
<tr>
<td>1</td>
<td><em>NULL</em></td>
<td>Home</td>
<td>0</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>Sporting Goods</td>
<td>1</td>
</tr>
<tr>
<td>3</td>
<td>2</td>
<td>Tennis</td>
<td>2</td>
</tr>
<tr>
<td>4</td>
<td>3</td>
<td>Racquets</td>
<td>3</td>
</tr>
<tr>
<td>5</td>
<td>4</td>
<td>Prince</td>
<td>4</td>
</tr>
<tr>
<td>6</td>
<td>4</td>
<td>Wilson</td>
<td>4</td>
</tr>
<tr>
<td>7</td>
<td>4</td>
<td>Head</td>
<td>4</td>
</tr>
<tr>
<td>8</td>
<td>4</td>
<td>Yonex</td>
<td>4</td>
</tr>
<tr>
<td>9</td>
<td>2</td>
<td>Golf</td>
<td>2</td>
</tr>
<tr>
<td>10</td>
<td>9</td>
<td>Drivers</td>
<td>3</td>
</tr>
<tr>
<td>11</td>
<td>10</td>
<td>Ping</td>
<td>4</td>
</tr>
<tr>
<td>12</td>
<td>10</td>
<td>TaylorMade</td>
<td>4</td>
</tr>
</table>
<p>Here&#8217;s the query I came up with:</p>
<pre style="border: 1px solid #000000; padding: 5px; margin-left: 40px">SELECT max(ltrim(sys_connect_by_path(site_area, ' > '),' > '))
FROM (
SELECT
site_area,
site_link,
row_number() over (partition by 1 order by site_level) level_index
FROM hierarchical_data
START WITH id=8
CONNECT BY PRIOR parent_id=id
)
START WITH level_index = 1
CONNECT BY level_index = prior level_index + 1;</pre>
<p>And the resulting data set:</p>
<table width="400" border="1">
<tr>
<th bgcolor="#c0c0c0" align="left">BREAD_CRUMBS</th>
</tr>
<tr>
<td>Home > Sporting Goods > Tennis > Racquets > Yonex</td>
</tr>
</table>
<p>Let me know what you think&#8230; and be nice.
</p>
]]></content:encoded>
			<wfw:commentRSS>http://www.openclosure.org/2007/10/15/hierarchical-data-sets/feed/</wfw:commentRSS>
		</item>
	</channel>
</rss>
