<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Clarity, Clarity, Clarity</title>
	<atom:link href="http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/</link>
	<description>Just another Oracle weblog</description>
	<lastBuildDate>Wed, 19 Jun 2013 12:03:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Log Buffer #17: a Carnival of the Vanities for DBAs</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-53379</link>
		<dc:creator><![CDATA[Log Buffer #17: a Carnival of the Vanities for DBAs]]></dc:creator>
		<pubDate>Mon, 04 Feb 2013 16:15:07 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-53379</guid>
		<description><![CDATA[[...] There&#8217;s a new kid on the blog &#8212; Jonathan Lewis, and his blog is the Oracle Scratchpad. Here&#8217;s a post of his on the virtues of clarity. And clarity and clarity. [...]]]></description>
		<content:encoded><![CDATA[<p>[...] There&#8217;s a new kid on the blog &#8212; Jonathan Lewis, and his blog is the Oracle Scratchpad. Here&#8217;s a post of his on the virtues of clarity. And clarity and clarity. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-130</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Nov 2006 16:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-130</guid>
		<description><![CDATA[Gabe, there are some instructions about allowing code to survive the comments editor in the page &quot;How to use&quot;.
If you want to email me your source, I&#039;ll reformat it and publish in your original note. In passing one of my &quot;rules&quot; on decode() is that if it&#039;s not a one-liner, then the closing bracket should either be under the opening &#039;d&#039;, or under the first letter of the predicate that it completes.]]></description>
		<content:encoded><![CDATA[<p>Gabe, there are some instructions about allowing code to survive the comments editor in the page &#8220;How to use&#8221;.<br />
If you want to email me your source, I&#8217;ll reformat it and publish in your original note. In passing one of my &#8220;rules&#8221; on decode() is that if it&#8217;s not a one-liner, then the closing bracket should either be under the opening &#8216;d&#8217;, or under the first letter of the predicate that it completes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabe</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-129</link>
		<dc:creator><![CDATA[Gabe]]></dc:creator>
		<pubDate>Fri, 10 Nov 2006 16:11:52 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-129</guid>
		<description><![CDATA[Oh well. Here goes the clarity part.
I did hit the back button and checked that my entire comment was there, formatted and all ... but it came out the way it did. So, that&#039;s that then. Sorry about the mess.]]></description>
		<content:encoded><![CDATA[<p>Oh well. Here goes the clarity part.<br />
I did hit the back button and checked that my entire comment was there, formatted and all &#8230; but it came out the way it did. So, that&#8217;s that then. Sorry about the mess.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabe</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-128</link>
		<dc:creator><![CDATA[Gabe]]></dc:creator>
		<pubDate>Fri, 10 Nov 2006 16:04:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-128</guid>
		<description><![CDATA[Ok, so we agree then: it is an issue of taste … as in, appearances. We just reached different conclusions. In fact, to me, it isn’t as much &lt;i&gt;commas at the beginning&lt;/i&gt; vs. &lt;i&gt;commas at the end&lt;/i&gt; as the commas being equally indented or better said, being in a predictable, consistent place. It is for reasons of readability that I prefer it.

I don’t want to fill your blog with some ugly, nested SQL; I’m sure you’ve seen enough of that. But here is something small:

select rownum id,
       decode(mod(rownum,10),0,null,
       decode(rownum-1,0,null,rownum-1)) pid,
       trunc(rownum/10) typ
from   (select level from dual connect by level bad taste&lt;/i&gt;, but as long as I see the pattern, I’m good.

Cheers.

PS. A preview button will be nice here … will my sql come out LTRIMed or not?]]></description>
		<content:encoded><![CDATA[<p>Ok, so we agree then: it is an issue of taste … as in, appearances. We just reached different conclusions. In fact, to me, it isn’t as much <i>commas at the beginning</i> vs. <i>commas at the end</i> as the commas being equally indented or better said, being in a predictable, consistent place. It is for reasons of readability that I prefer it.</p>
<p>I don’t want to fill your blog with some ugly, nested SQL; I’m sure you’ve seen enough of that. But here is something small:</p>
<p>select rownum id,<br />
       decode(mod(rownum,10),0,null,<br />
       decode(rownum-1,0,null,rownum-1)) pid,<br />
       trunc(rownum/10) typ<br />
from   (select level from dual connect by level bad taste, but as long as I see the pattern, I’m good.</p>
<p>Cheers.</p>
<p>PS. A preview button will be nice here … will my sql come out LTRIMed or not?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-126</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Fri, 10 Nov 2006 07:25:08 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-126</guid>
		<description><![CDATA[Gabe,  I have heard arguments for the &quot;commas at beginning&quot; - the worst one was that it&#039;s easier for code-generators. There&#039;s also the one about being able to delete lines more easily (which also applies to &quot;and at the end&quot;). Since I have to read code, I&#039;ll always argue for styles that make it easier for readers, rather than writers.
On Unix I use vi, on Windows I use notepad, on VMS I use ed, on mainframes I use whatever they&#039;ve got.]]></description>
		<content:encoded><![CDATA[<p>Gabe,  I have heard arguments for the &#8220;commas at beginning&#8221; &#8211; the worst one was that it&#8217;s easier for code-generators. There&#8217;s also the one about being able to delete lines more easily (which also applies to &#8220;and at the end&#8221;). Since I have to read code, I&#8217;ll always argue for styles that make it easier for readers, rather than writers.<br />
On Unix I use vi, on Windows I use notepad, on VMS I use ed, on mainframes I use whatever they&#8217;ve got.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gabe</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-120</link>
		<dc:creator><![CDATA[Gabe]]></dc:creator>
		<pubDate>Fri, 10 Nov 2006 00:08:38 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-120</guid>
		<description><![CDATA[&lt;i&gt;I also happen to dislike [snip] commas at the beginning of lines, but at least I can tell myself that that’s just a sign of poor taste.&lt;/i&gt;
Fair comment.
I&#039;m guilty as charged then ... and I&#039;ll stay that way. Mind you, there is a reason for that &lt;i&gt;poor taste&lt;/i&gt;. Just curious ... what editor do you prefer when writing code?

]]></description>
		<content:encoded><![CDATA[<p><i>I also happen to dislike [snip] commas at the beginning of lines, but at least I can tell myself that that’s just a sign of poor taste.</i><br />
Fair comment.<br />
I&#8217;m guilty as charged then &#8230; and I&#8217;ll stay that way. Mind you, there is a reason for that <i>poor taste</i>. Just curious &#8230; what editor do you prefer when writing code?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Lewis</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-99</link>
		<dc:creator><![CDATA[Jonathan Lewis]]></dc:creator>
		<pubDate>Wed, 08 Nov 2006 07:56:02 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-99</guid>
		<description><![CDATA[Klabu, &lt;/em&gt;&quot;order of the from clause&quot;&lt;/em&gt; ... top to bottom, i.e. &quot;lkd down to &quot;ses&quot;. And to reduce the risk of any other ambiguity, this is reading down the left hand side of the predicates.
Of course if I had to write SQL for the Rule Based Optimiser I would put the tables in the &lt;em&gt;from&lt;/em&gt; clause in the reverse order because the RBO works from the bottom up (all other things being equal).  This means that for RBO, my table ordering in the &lt;em&gt;from&lt;/em&gt; and my predicate ordering in the &lt;em&gt;where&lt;/em&gt; used (at the global level) to run in opposite directions to each other.
(Within any one table, the same bottom-up to top-down rule switch still applies for filter predicates though, consider :
&lt;code&gt;
where
    colx = 99
and coyY = &#039;A&#039;
&lt;/code&gt;
RBO operates these from the bottom up, CBO operates them from the top down.)
]]></description>
		<content:encoded><![CDATA[<p>Klabu, &#8220;order of the from clause&#8221; &#8230; top to bottom, i.e. &#8220;lkd down to &#8220;ses&#8221;. And to reduce the risk of any other ambiguity, this is reading down the left hand side of the predicates.<br />
Of course if I had to write SQL for the Rule Based Optimiser I would put the tables in the <em>from</em> clause in the reverse order because the RBO works from the bottom up (all other things being equal).  This means that for RBO, my table ordering in the <em>from</em> and my predicate ordering in the <em>where</em> used (at the global level) to run in opposite directions to each other.<br />
(Within any one table, the same bottom-up to top-down rule switch still applies for filter predicates though, consider :<br />
<code><br />
where<br />
    colx = 99<br />
and coyY = 'A'<br />
</code><br />
RBO operates these from the bottom up, CBO operates them from the top down.)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: klabu</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-98</link>
		<dc:creator><![CDATA[klabu]]></dc:creator>
		<pubDate>Wed, 08 Nov 2006 03:55:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-98</guid>
		<description><![CDATA[&gt;&gt; Third I list the table names in the from clause in the order that I think the (cost-based) optimizer ought to visit them. The same ordering pattern appears in the where clause.
&lt;code&gt;
select
from
	v$locked_object		lkd,
	dba_objects		obj,
	dba_rollback_segs	rbs,
	v$transaction		trn,
	v$session		ses
where
	obj.object_id  = lkd.object_id
and	rbs.segment_id = lkd.xidusn
and	trn.xidusn     = lkd.xidusn
and	trn.xidslot    = lkd.xidslot
and	trn.xidsqn     = lkd.xidsqn	-- added for completeness
and	ses.taddr      = trn.addr
&lt;&lt;
&lt;/code&gt;

So what is the order ???
&quot;lkd&quot; down to -&gt; &quot;ses&quot;
or the reverse ?
Thanks

]]></description>
		<content:encoded><![CDATA[<p>&gt;&gt; Third I list the table names in the from clause in the order that I think the (cost-based) optimizer ought to visit them. The same ordering pattern appears in the where clause.<br />
<code><br />
select<br />
from<br />
	v$locked_object		lkd,<br />
	dba_objects		obj,<br />
	dba_rollback_segs	rbs,<br />
	v$transaction		trn,<br />
	v$session		ses<br />
where<br />
	obj.object_id  = lkd.object_id<br />
and	rbs.segment_id = lkd.xidusn<br />
and	trn.xidusn     = lkd.xidusn<br />
and	trn.xidslot    = lkd.xidslot<br />
and	trn.xidsqn     = lkd.xidsqn	-- added for completeness<br />
and	ses.taddr      = trn.addr<br />
&lt;&lt;<br />
</code></p>
<p>So what is the order ???<br />
&#8220;lkd&#8221; down to -&gt; &#8220;ses&#8221;<br />
or the reverse ?<br />
Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: William Robertson</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-80</link>
		<dc:creator><![CDATA[William Robertson]]></dc:creator>
		<pubDate>Mon, 06 Nov 2006 13:16:58 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-80</guid>
		<description><![CDATA[I don&#039;t see how this depends on developers following conventions. I didn&#039;t learn to write my join predicates the way I do by following a convention, I learned it all in the School of Hard Knocks.

The issue doesn&#039;t go away with ANSI join syntax either. There is nothing to stop you writing

FROM a
JOIN b ON a.col = b.col

which to me, though not to everyone else apparently, is inconsistent with

WHERE b.deptno IS NULL

in that both specify something about a column of table B, but that column appears on arbitrarily different sides of the expression.

For ANSI outer joins we could even write

FROM b
RIGHT OUTER JOIN a ON a.col = b.col

which only makes the slightest sense if you read the query backwards.]]></description>
		<content:encoded><![CDATA[<p>I don&#8217;t see how this depends on developers following conventions. I didn&#8217;t learn to write my join predicates the way I do by following a convention, I learned it all in the School of Hard Knocks.</p>
<p>The issue doesn&#8217;t go away with ANSI join syntax either. There is nothing to stop you writing</p>
<p>FROM a<br />
JOIN b ON a.col = b.col</p>
<p>which to me, though not to everyone else apparently, is inconsistent with</p>
<p>WHERE b.deptno IS NULL</p>
<p>in that both specify something about a column of table B, but that column appears on arbitrarily different sides of the expression.</p>
<p>For ANSI outer joins we could even write</p>
<p>FROM b<br />
RIGHT OUTER JOIN a ON a.col = b.col</p>
<p>which only makes the slightest sense if you read the query backwards.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Aldridge</title>
		<link>http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-78</link>
		<dc:creator><![CDATA[David Aldridge]]></dc:creator>
		<pubDate>Sun, 05 Nov 2006 15:47:29 +0000</pubDate>
		<guid isPermaLink="false">http://jonathanlewis.wordpress.com/2006/11/02/clarity-clarity-clarity/#comment-78</guid>
		<description><![CDATA[&gt;&gt; ... I edited your previous comment back into one piece 

And not for the first time I think. Thanks ... I&#039;m going to try to have to remember not to write less-than signs.

You could well be right about the joins/predicate thing Jonathan, and maybe we encroach on differences between relational and SQL databases here. I&#039;m pretty sure that in the pure relational sense there is a big difference, with selections, theta-joins, division. antijoins and whatnot, but the lines get blurred when one starts to consider the implementation in the RDBMS -- maybe more particularly in a &quot;SQL DBMS&quot;. Maybe my differentiation between joins and predicates in SQL is just a relational pretension, but I&#039;m not at all sure that I can give it up. When visualising queries I always find myself linking up tables with joins and then asa second step imposing the predicates on the result -- if it is in one&#039;s nature to imagine predicates on the leading table before joining up to other tables then I can see how &quot;B=A, C=B&quot; makes more sense. Maybe I should just start using the ANSI join syntax, but I&#039;m not sure that I can take that step yet either :(

I like the idea of improving maintainability by documenting expected join order but it depends on an established convention that says &quot;all developers will order joins in this manner&quot; and once you have established a convention then the style of the convention matters less than that everyone stick to it. Compliance to that convention would be very tricky to check by eye, and if one was going to be super-rigourous in this respect then I&#039;d be wanting some form of abbreviated explain plan appended as a comment. Or maybe that&#039;s going too far ... the more important part of the convention is that it is respected by all.

Let me just add on a note of self-interest that if someone is paying me cash-money to write code then I&#039;ll adopt almost any convention they like, even to the extent of not using mixed-case. But I won&#039;t do code in all upper-case -- I&#039;ll see myself and family destitute first :D]]></description>
		<content:encoded><![CDATA[<p>&gt;&gt; &#8230; I edited your previous comment back into one piece </p>
<p>And not for the first time I think. Thanks &#8230; I&#8217;m going to try to have to remember not to write less-than signs.</p>
<p>You could well be right about the joins/predicate thing Jonathan, and maybe we encroach on differences between relational and SQL databases here. I&#8217;m pretty sure that in the pure relational sense there is a big difference, with selections, theta-joins, division. antijoins and whatnot, but the lines get blurred when one starts to consider the implementation in the RDBMS &#8212; maybe more particularly in a &#8220;SQL DBMS&#8221;. Maybe my differentiation between joins and predicates in SQL is just a relational pretension, but I&#8217;m not at all sure that I can give it up. When visualising queries I always find myself linking up tables with joins and then asa second step imposing the predicates on the result &#8212; if it is in one&#8217;s nature to imagine predicates on the leading table before joining up to other tables then I can see how &#8220;B=A, C=B&#8221; makes more sense. Maybe I should just start using the ANSI join syntax, but I&#8217;m not sure that I can take that step yet either :(</p>
<p>I like the idea of improving maintainability by documenting expected join order but it depends on an established convention that says &#8220;all developers will order joins in this manner&#8221; and once you have established a convention then the style of the convention matters less than that everyone stick to it. Compliance to that convention would be very tricky to check by eye, and if one was going to be super-rigourous in this respect then I&#8217;d be wanting some form of abbreviated explain plan appended as a comment. Or maybe that&#8217;s going too far &#8230; the more important part of the convention is that it is respected by all.</p>
<p>Let me just add on a note of self-interest that if someone is paying me cash-money to write code then I&#8217;ll adopt almost any convention they like, even to the extent of not using mixed-case. But I won&#8217;t do code in all upper-case &#8212; I&#8217;ll see myself and family destitute first :D</p>
]]></content:encoded>
	</item>
</channel>
</rss>
