<?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>WebProNews &#187; Best Practices</title>
	<atom:link href="http://www.webpronews.com/tag/best-practices/feed" rel="self" type="application/rss+xml" />
	<link>http://www.webpronews.com</link>
	<description>Breaking News in Tech, Search, Social, &#38; Business</description>
	<lastBuildDate>Mon, 13 Feb 2012 22:07:28 +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>Practice Makes Perfect For SQL</title>
		<link>http://www.webpronews.com/practice-makes-perfect-for-sql-2006-09</link>
		<comments>http://www.webpronews.com/practice-makes-perfect-for-sql-2006-09#comments</comments>
		<pubDate>Tue, 12 Sep 2006 18:11:16 +0000</pubDate>
		<dc:creator>WebProNews Staff</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[blog]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Sheeri Kritzer]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.webpronews.com/?p=31432</guid>
		<description><![CDATA[MySQL guru Sheeri Kritzer listed eight SQL best practices for database professionals who are hard at work on their projects.
]]></description>
			<content:encoded><![CDATA[<p>MySQL guru Sheeri Kritzer listed eight SQL best practices for database professionals who are hard at work on their projects.</p>
<table width="128" border="0" align="right">
<tr>
<td width="122" height="62"><a href="http://www.webproworld.com/viewtopic.php?p=323159"><img src="http://images.ientrymail.com/CommentImage-4.gif" width="130" height="60" border="0"></a></td>
</tr>
</table>
<p>Kritzer&#8217;s <a href=http://sheeri.com/archives/104 class=bluelink>list</a> began with a preface on why she tries to live by the eight SQL rules in her post about best practices:</p>
<p><i>
<div style=margin-left:10px; margin-right:10px>In declarative languages like SQL, you program what you want the result to be, not the procedure to get it. For instance, &#8220;give me all the people with the first name starting with the letter S from a certain table.&#8221; </p>
<p>Unlike procedural programming (or even methods in object-oriented languages), you do not say how to get the information. This is, I believe, why many developers want to give the query optimizer &#8220;hints&#8221; on how to do its job.</p></div>
<p></i><br />
Kritzer started the list by suggesting database developers always use explicit joins. &#8220;If I mean INNER JOIN, then I use INNER JOIN. No use of just plain &#8220;JOIN&#8221;. Never, ever, ever use a comma join &#8211; I consider that a mistake,&#8221; she wrote.</p>
<p>One person asked about that practice in a comment about the post. Peter Zaitsev of the <a href=http://www.mysqlperformanceblog.com/ class=bluelink>MySQL Performance Blog</a> said this:</p>
<p><i>
<div style=margin-left:10px; margin-right:10px>I personally feel this is syntax matter, unless you use LEFT JOIN. Some people find it more readable, some not &#8211; I would for example like to see clauses grouped by tables as for inner join there is no difference between where and on clauses for optimizer and I prefer to see how query can be executed easily.</div>
<p></i><br />
Kritzer agreed in her response that the use of explicit joins is definitely syntax. &#8220;I feel that specifying INNER vs. LEFT or RIGHT or CROSS helps them understand that they&#8217;re not saying &#8220;I want you to join the tables,&#8221; ie, take an action, they&#8217;re saying, &#8220;I want the result if you join the tables this way,&#8221; ie, &#8220;this is what I want back.&#8221;</div>
<p></i><br />
Database pros should not be afraid of JOINS. If good indexing has been used for the database, Krtizer said JOINS are not necessarily resource-intensive. And when a correlated subquery can be replaced with a JOIN, it should be replaced.</p>
<p>Developers should also always define field names. &#8220;No using SELECT * or INSERT INTO table VALUES. It&#8217;s a pain,&#8221; she wrote. For reporting, always use the timestamp from the database server, in case those of web servers are different.</p>
<p>Reporting will go more smoothly if one stores IPs as integers with INET_ATON and retrieves them with INET_NTOA, Kritzer also wrote. On the topic of reporting, she considered the impact of network traffic and made this best practice suggestion:</p>
<p><i>
<div style=margin-left:10px; margin-right:10px>If you&#8217;re going to receive information, it&#8217;s better to receive in chunks, which will likely be larger than a logical piece. For instance, state reporting &#8211; instead of making 50 connections for states in the US, get them all at once. </p>
<p>If the dataset is very large and folks do not want to stare at a blank page while the report is loading, use paging with LIMIT to grab, say, 1000 entries at a time and display them on the screen so people can start looking at the data while the rest is being grabbed.</p></div>
<p></i><br />
&#8220;Running a query in a loop is usually a bad idea,&#8221; Kritzer said of those. &#8220;Consider building a query string using UNION and executing it at the end of the loop, so you can execute multiple queries with only one trip across the network to the database.&#8221;</p>
<p>&#8212;</p>
<p>Add to <a href="http://del.icio.us/post" onclick="window.open('http://del.icio.us/post?v=4&#038;partner=wpn&#038;noui&#038;jump=close&#038;url='+encodeURIComponent(location.href)+'&#038;title='+encodeURIComponent(document.title),'delicious','toolbar=no,width=700,height=400'); return false;" CLASS="printMailTop"><img src=http://images1.ientrymail.com/webpronews/delicious-pic.png border=0> Del.icio.us</a> | <a href="javascript:void window.open('http://digg.com/submit?phase=2&#038;url='+encodeURIComponent(window.location.href)+'&#038;ei=UTF-8','popup','width=520px,height=420px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0)"><img src=http://images1.ientrymail.com/webpronews/digg-pic.png border=0> Digg</a>  | <a href="javascript:void window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+encodeURIComponent(document.title)+'&#038;u='+encodeURIComponent(window.location.href)+'&#038;tag=Sheeri Kritzer,SQL,Best Practices','popup','width=520px,height=420px,status=0,location=0,resizable=1,scrollbars=1,left=100,top=50',0)"><img src=http://images1.ientrymail.com/webpronews/yahoo-pic.png border=0> Yahoo! My Web</a> | <a href="javascript:location.href='http://www.furl.net/storeIt.jsp?u='+encodeURIComponent(document.location.href)+'&#038;t='+encodeURIComponent(document.title)+' '"><img src=http://images1.ientrymail.com/webpronews/furl-pic.png border=0> Furl</a></p>
<p>Bookmark WebProNews: <a href=http://www.webpronews.com><img src=http://images.ientrymail.com/webpronews/wpn-readit.jpg border=0></a> </p>
<p><script language=JavaScript src="http://aj.600z.com/aj/1095/0/vj?z=1&#038;dim=1088&#038;pos=15"></script></p>
<p>David Utter is a staff writer for WebProNews covering technology and business. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webpronews.com/practice-makes-perfect-for-sql-2006-09/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 1/9 queries in 0.006 seconds using memcached
Object Caching 199/212 objects using memcached

Served from: webpronews.com @ 2012-02-13 17:11:56 -->
