<?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>kwatog &#38; co.&#187; subquery optimization</title>
	<atom:link href="http://kwatog.com/tag/subquery-optimization/feed/" rel="self" type="application/rss+xml" />
	<link>http://kwatog.com</link>
	<description>tech notes and general nonsense</description>
	<lastBuildDate>Tue, 31 Jan 2012 06:27:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Oracle WITH Clause  (Subquery Refactoring)</title>
		<link>http://kwatog.com/blog/oracle/oracle-with-clause-subquery-factoring/</link>
		<comments>http://kwatog.com/blog/oracle/oracle-with-clause-subquery-factoring/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 11:48:57 +0000</pubDate>
		<dc:creator>kwatog</dc:creator>
				<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PL/SQL]]></category>
		<category><![CDATA[subquery optimization]]></category>
		<category><![CDATA[WITH]]></category>
		<guid isPermaLink="false">http://kwatog.com/?p=187</guid>
		<description><![CDATA[WITH clause was introduced in Oracle 9i to provide powerful new syntax for enhancing query performance. It optimizes query speed by eliminating redundant processing in complex queries. WITH Clause Syntax WITH alias_name -- alias for the aggregate_query AS (aggregate_query_here) SELECT... -- Beginning of the query main body It should be noted that multiple aggregate queries [...]]]></description>
			<content:encoded><![CDATA[<p>WITH clause was introduced in Oracle 9i to provide powerful new syntax for enhancing query performance. It optimizes query speed by eliminating redundant processing in complex queries. </p>
<h3>WITH Clause Syntax</h3>
<pre name="code" class="sql">
WITH
 alias_name         -- alias for the aggregate_query
AS
 (aggregate_query_here)
SELECT...            -- Beginning of the query main body
</pre>
<p>It should be noted that multiple aggregate queries can be defined in the WITH clause as below.</p>
<pre name="code" class="sql">
WITH
 alias_name1
AS
 (agg_query1) ,
 alias_name2
AS
 (agg_query2)
SELECT...
</pre>
<p>When using subquery factoring, think of the aggregate_query as an in-line view. Actually, it is a view but a temporary one. Instead of creating a permanent view accessible in the database, you are creating a temporary one exclusively used by your main query. </p>
<h3>Usage</h3>
<p>I primarily use this in creating adhoc queries, reports and extractions. Of course, you can just create a view to accomplish this task. However, there are times wherein you are not allowed to create additional objects in the database for one reason or another. In that case, this subquery optimization comes very handy. </p>
<h3>Caveat</h3>
<p>You can&#8217;t use this inside Oracle Forms. It also doesn&#8217;t work inside stored procedures or anything with PL/SQL in it. At least I&#8217;m talking about until 11g. </p>
<h4>Incoming search terms:</h4><ul><li>oracle with clause</li><li>with clause in oracle</li><li>oracle with clause syntax</li><li>oracle sql subquery refactor</li><li>subquery factoring in plsql</li><li>subquery factoring clause + procedure</li><li>subquery optimization pl-sql</li><li>subquery refactoring oracle</li><li>subquery sp oracle</li><li>subselect inside case clause oracle</li></ul>]]></content:encoded>
			<wfw:commentRss>http://kwatog.com/blog/oracle/oracle-with-clause-subquery-factoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!--
Hyper cache file: cd9ff55b14437474026e904198ce78d7
Cache created: 07-02-2012 18:45:40
HCE Version: 0.9.8
Load AVG: 0(5)
-->
