<?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>SQL in the Wild &#187; Rants</title>
	<atom:link href="http://sqlinthewild.co.za/index.php/category/rants/feed/" rel="self" type="application/rss+xml" />
	<link>http://sqlinthewild.co.za</link>
	<description>A discussion on SQL Server</description>
	<lastBuildDate>Sun, 01 Jan 2012 14:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>DBA Hell</title>
		<link>http://sqlinthewild.co.za/index.php/2010/06/15/dba-hell/</link>
		<comments>http://sqlinthewild.co.za/index.php/2010/06/15/dba-hell/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 14:00:46 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Syndication]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=605</guid>
		<description><![CDATA[On the first day of DBA hell, the server gave to me A database with damaged system tables and no good backups (1) On the second day of DBA hell, the server gave to me Two databases with widespread corruption, no backups (1, 2) On the third day of DBA hell, the server gave to [...]]]></description>
			<content:encoded><![CDATA[<p>On the first day of DBA hell, the server gave to me<br />
A database with damaged system tables and no good backups (<a href="http://www.sqlservercentral.com/Forums/Topic922090-146-1.aspx">1</a>)</p>
<p>On the second day of DBA hell, the server gave to me<br />
Two databases with widespread corruption, no backups (<a href="http://www.sqlservercentral.com/Forums/Topic930861-266-1.aspx">1</a>, <a href="http://www.sqlservercentral.com/Forums/Topic926497-266-1.aspx">2</a>)</p>
<p>On the third day of DBA hell, the server gave to me<br />
Three suspect databases, no backups (<a href="http://www.sqlservercentral.com/Forums/Topic930198-266-1.aspx">1</a>,<a href="http://www.sqlservercentral.com/Forums/Topic930240-391-1.aspx">2</a>,<a href="http://www.sqlservercentral.com/Forums/Topic922754-146-1.aspx">3</a>)</p>
<p>On the fourth day of DBA hell, the server gave me nothing, cause I didn&#8217;t have a job any longer…</p>
<p>How does one end up with a critical production database that has no backups? I could kinda understand if the backups were damaged, if the corruption went undetected for long enough that it was in the backups as well, but to have no backups at all? Of an important database?</p>
<p>The only excuse for having no backups is if the database can be trivially and completely recreated from another source with minimal impact to the users. This is not the normal scenario.</p>
<p>There&#8217;s an immense amount of information available on backup and restore strategies.</p>
<ul>
<li>&#8220;<a href="http://msdn.microsoft.com/en-us/library/ms191239.aspx">Introduction to backup and restore strategies</a>&#8221; on MSDN</li>
<li>Paul Randal&#8217;s Technet article &#8220;<a href="http://technet.microsoft.com/en-us/magazinebeta/2009.07.sqlbackup.aspx">Understanding SQL Server backups</a>&#8220;</li>
<li>Paul Randal&#8217;s presentation to the SQLPass DBA Virtual Chapter &#8220;<a href="http://dba.sqlpass.org/MeetingArchive.aspx">Building the Right Backup Strategy</a>&#8221; (not available for download at this point, check back in a few days)</li>
</ul>
<p>That&#8217;s just a quick list, there&#8217;s far more information available than that. Enough that there&#8217;s really no good excuse to not have backups when they&#8217;re needed.</p>
<p>As Steve Jones (<a href="http://www.sqlservercentral.com/blogs/steve_jones/">blog</a>|<a href="http://twitter.com/way0utwest">twitter</a>) is fond of saying &#8220;Good backup, good resume. You only need one&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2010/06/15/dba-hell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Root of all Evil</title>
		<link>http://sqlinthewild.co.za/index.php/2010/03/11/the-root-of-all-evil/</link>
		<comments>http://sqlinthewild.co.za/index.php/2010/03/11/the-root-of-all-evil/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 14:00:51 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Performance]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Syndication]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=563</guid>
		<description><![CDATA[Or “Shot gun query tuning” There have been a fair few forums questions in recent months asking for help in removing index scans, loop joins, sorts or other, presumed, slow query operators. There have been just as many asking how to replace a subquery with a join or a join with a subquery or similar [...]]]></description>
			<content:encoded><![CDATA[<p>Or “<em>Shot gun query tuning</em>”</p>
<p>There have been a fair few forums questions in recent months asking for help in removing index scans, loop joins, sorts or other, presumed, slow query operators. There have been just as many asking how to replace a subquery with a join or a join with a subquery or similar aspects of a query usually for performance reasons.</p>
<p>The first question that I have to ask when looking at requests like that is &#8220;Why?&#8221;</p>
<p>Why is removing a particular query operator the goal? Why is changing a where clause predicate the goal? If it’s to make the query faster, has the query been examined and has it been confirmed that query operator or predicate really is the problem?</p>
<p>The title of this post refers to a comment I’ve seen again and again in blogs or articles about front-end development. &#8220;<em>Premature optimisation is the root of all evils.</em>&#8221; It’s true in the database field as well.</p>
<p><span id="more-563"></span></p>
<p>While optimisation is very important in database development, trying to optimise queries without any idea where the problem with the query is, or even if the query is a problem at all is about as effective in fixing a database performance problem as using a shotgun from 100 meters is in killing mosquitoes. If you hit the problem, it’s by shear luck and nothing else.</p>
<p>There&#8217;s two sides to this problem.</p>
<p>The first aspect of this is, during development, spending time on optimising a query (or stored procedure) without any idea whether or not the query is inefficient and no idea whether or not the changes made make any improvement or not.</p>
<p>Firstly this is a waste of time that could be better spent developing other queries. Second it creates an incorrect impression that the queries have been optimised when in fact nothing of the sort has been done.</p>
<p>The second aspect when, with a production database that is performing badly, queries are modified almost at random in an attempt to fix the performance problem quickly.</p>
<p>This almost never works. It wastes time fixing stuff that very likely isn&#8217;t broken in the first place all the while the database performance deteriorates and management curses SQL Server as &#8216;nonscalable&#8217;</p>
<p>So, what is the right approach for the above two scenarios?</p>
<ol>
<li>Don&#8217;t optimise queries without knowing if they need it.</li>
<li>Don&#8217;t optimise queries without knowing if they need it. <sup>1</sup></li>
</ol>
<h3>New development</h3>
<p>When writing queries and stored procedures they need to be tested against a representative data set on a server with representative workload and their performance characteristics evaluated to see if they are acceptable. If the query&#8217;s performance characteristics are acceptable, then that query requires no optimisation<sup>2</sup></p>
<p>This doesn&#8217;t mean write bad code and push it to production. It means write good, solid code, following accepted coding standards, ensure that it runs acceptably against production-volumes of data, and do not spend hours or days trying to get it running a couple of milliseconds faster.</p>
<p>And if the query doesn&#8217;t perform acceptable, identify the problematic portion and fix that, don&#8217;t flail around rewriting bits of the query in the hope that the problem will magically go away.</p>
<p>The execution plan is the primary tool here, along with the output of Statistics IO.</p>
<h3>Fixing existing code</h3>
<p>When evaluating existing databases with know performance problems, limit the performance tuning to queries that really are performing badly and need optimisation. It&#8217;s often true that fixing the top 5-10 worst performing queries will have massive effects in overall system performance, far more than tuning twice that number of queries that aren&#8217;t really a problem.</p>
<p>The best tool for finding which queries really are the worst offenders is SQL Trace.</p>
<p>When looking at queries that are a problem, identify the portions that are inefficient and target attempts at optimisation towards those problems.</p>
<h3>In conclusion</h3>
<p>Measure Twice.<br />
Optimise if necessary.</p>
<hr />
<p>(1) No, that wasn&#8217;t a typo.</p>
<p>(2) At that time. Later changes to schema or data volume may require existing queries to be revised.</p>
<p>For more details on exactly how to identify problematic queries, refer to the <a href="http://www.simple-talk.com/sql/performance/finding-the-causes-of-poor-performance-in-sql-server,-part-1/">series I wrote at Simple Talk</a> last year.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2010/03/11/the-root-of-all-evil/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Developers vs DBAs</title>
		<link>http://sqlinthewild.co.za/index.php/2009/04/17/developers-vs-dbas/</link>
		<comments>http://sqlinthewild.co.za/index.php/2009/04/17/developers-vs-dbas/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 22:00:49 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=234</guid>
		<description><![CDATA[I was listening to a podcast on nHibernate this morning. Most of it was very good, but there was one section that absolutly made me see red. The guest on the show was asked how the DBAs felt about the use of nHibernate for a new app on an existing (old) database. The reply essentially [...]]]></description>
			<content:encoded><![CDATA[<p>I was listening to a podcast on nHibernate this morning. Most of it was very good, but there was one section that absolutly made me see red.</p>
<p>The guest on the show was asked how the DBAs felt about the use of nHibernate for a new app on an existing (old) database. The reply essentially was &#8216;We haven&#8217;t told them and we&#8217;re not going to tell them.&#8217; Apparently the plan was to only tell the DBAs about this app if there was a problem with it in production</p>
<p>Now there&#8217;s a whole lot of problems with that scenario and I can sum most of them up in one word &#8211; Trust.</p>
<p>If an application was mostly to be written in C#, but there was a critical portion that depended on (say) Biztalk no one would seriously suggest keeping the biztalk expert on staff in the dark and doing it completely themselves. So why do developers do that with databases?</p>
<p>I&#8217;ve often heard developers complain that the DBA doesn&#8217;t trust them. Guess what, pull this kind of stunt and they&#8217;ve got a good reason for not trusting those developers. Go behind someone&#8217;s back, hide stuff from them and they&#8217;re not going to trust you. No big surprise there.</p>
<p>The whole &#8216;them and us&#8217; attitude that a lot of developers and DBAs have is, quite frankly, stupid and highly counter productive. The DBAs are the ones responsible for the database portion of custom apps after they become production, they should have some input during the development phase whether it be on the database design, the stored procedures or just ensuring that the app will scale to the required production load.</p>
<p>So, in conclusion&#8230;</p>
<p>Developers, speak to the DBAs, get them involved in projects early. You may be surprised how much value they can add to the project and how much smoother things can go when everyone&#8217;s working together instead of fighting each other. Of course, if your DBAs are the arrogant, overbearing type that give the profession a bad name, if may not be that easy.</p>
<p>DBAs, if you know that the developers avoid you, hide projects and prefer to go their own way, first take a look at your own behaviour. Ask to be involved in the early stages of development. Chat with the developers, see if there&#8217;s anything that you can help out with or any areas that they need assistance. You may be surprised how many problems can be ironed out before they become problems in the production environment. Of course, if your developers are they type that triggered this rant, it may not be that easy.</p>
<p>&lt;/soapbox&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2009/04/17/developers-vs-dbas/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Bad Advice</title>
		<link>http://sqlinthewild.co.za/index.php/2009/01/22/bad-advice/</link>
		<comments>http://sqlinthewild.co.za/index.php/2009/01/22/bad-advice/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 16:21:04 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/?p=198</guid>
		<description><![CDATA[It&#8217;s no secret that I&#8217;ve been fairly active on a couple of SQL forums for a couple of years. In that time I&#8217;ve seen all sorts of behaviour on forums, good and bad. By this point, most of that just doesn&#8217;t bother me any longer. There is one thing however that still gets me angry [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s no secret that I&#8217;ve been fairly active on a couple of SQL forums for a couple of years. In that time I&#8217;ve seen all sorts of behaviour on forums, good and bad. By this point, most of that just doesn&#8217;t bother me any longer. There is one thing however that still gets me angry when I see it. Blatently bad advice.</p>
<p>Now, I&#8217;m not talking about first-attempt solutions that solve half of the query problem, I&#8217;m not talking about honest mistakes and I&#8217;m not talking about attempted answers to questions so vague they&#8217;re near-impossible to understand. I&#8217;m talking about advice that&#8217;s so bad it&#8217;s dangerous. I&#8217;m talking about things like this:</p>
<p>Q: My transaction log&#8217;s very large. What can I do to fix this?<br />
A: Stop SQL, find the ldf file, delete it and then start SQL</p>
<p>Q: Dropping a clustered index on a large table takes a long time using drop index. Is there a faster way?<br />
A: Run sp_configure &#8220;allow updates, 1 and then run delete from sysindexes where id = OBJECT_ID(&#8216;MyTableName&#8217;) AND indid = 1</p>
<p>Ouch!</p>
<p>There&#8217;s two main problems with bad advice.</p>
<p>Firstly, the person asking possibly doesn&#8217;t understand enought to realise the advice is risky, and if they follow it without testing they could end up in a much worse situation than they were. Dependiong on the circumstances they may end up in trouble with their boss, they may even end up getting fired. Whether they realise the advice is bad before or after trying it out, it&#8217;ll erode their faith both in the forum and in the person who provided the information. That leads to the the second problem.</p>
<p>The second problem is damaged credibility and reputation. A good reputation is so hard to get in this industry and so easy to lose. Bad advice damages the forum&#8217;s reputation and the reputation of the person posting the advice. <a href="http://www.brentozar.com/archive/2008/11/so-you-wanna-be-a-rock-roll-star-part-2/">Brent Ozar</a> puts it very well: &#8220;Being an expert means having credibility. It doesn’t matter how much you know if people don’t trust your answers.&#8221;</p>
<p>Then, of course, some other person on the forum has to come along and correct the bad advice and explain why it&#8217;s bad so that people who find the thread via google won&#8217;t think it&#8217;s useful</p>
<p>Bottom line, bad advice helps no one and hurts a number of people.</p>
<p>&lt;/soapbox&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2009/01/22/bad-advice/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>SQL Injection</title>
		<link>http://sqlinthewild.co.za/index.php/2008/05/07/sql-injection/</link>
		<comments>http://sqlinthewild.co.za/index.php/2008/05/07/sql-injection/#comments</comments>
		<pubDate>Wed, 07 May 2008 19:52:33 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2008/05/07/sql-injection/</guid>
		<description><![CDATA[This is a bit of a rant, so please ignore it you&#8217;re looking for technical info. There&#8217;s been a fair bit of news on SQL injection in the last week or so. Mainly cause some people figured out a way to automate the exploit. What scares me if the widespread lack of knowledge of SQL [...]]]></description>
			<content:encoded><![CDATA[<p>This is a bit of a rant, so please ignore it you&#8217;re looking for technical info.</p>
<p>There&#8217;s been a fair bit of <a href="http://blog.wired.com/monkeybites/2008/04/microsoft-datab.html">news on SQL injection</a> in the last week or so. Mainly cause some people figured out a way to automate the exploit.</p>
<p>What scares me if the widespread lack of knowledge of SQL injection. I&#8217;m fairly active on a couple of the SQL forums and on monday this week there were 2 posts by people who have had their databases hacked via a SQL injection exploit.</p>
<p>If this was a new exploit, I wouldn&#8217;t be so disappointed, but it&#8217;s not. SQL injection&#8217;s been around for years. I first read about it in 2001 when I started in web development.</p>
<p>So, why 7 years later are people still being hit with it? Why does a quick google search turn up a number of web sites with <strong>entire queries</strong> in the url? Sites including some government organisations, a couple of police departments, online stores and the coast guard (No, I&#8217;m not posting links. Search for yourself if you&#8217;re curious)</p>
<p>Completely preventing SQL injection is not hard. If web pages call the database using properly parameterised calls to stored procedures then SQL injection cannot be done. Set minimum permissions in the database for the web user and it&#8217;s even more secure.</p>
<p>So, why is it that so many sites, new and old, are still vulnerable?</p>
<p>Edit: For some in-depth info on preventing SQL injection, see <a href="http://blogs.technet.com/swi/archive/2008/05/29/sql-injection-attack.aspx">this blog post</a> on Technet</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2008/05/07/sql-injection/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>On recoverability</title>
		<link>http://sqlinthewild.co.za/index.php/2008/03/06/on-recoverability/</link>
		<comments>http://sqlinthewild.co.za/index.php/2008/03/06/on-recoverability/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 21:19:13 +0000</pubDate>
		<dc:creator>Gail</dc:creator>
				<category><![CDATA[Admin]]></category>
		<category><![CDATA[Rants]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://sqlinthewild.co.za/index.php/2008/03/06/on-recoverability/</guid>
		<description><![CDATA[Had a lovely situation this morning. I can&#8217;t go into details, but essentially a database had no off-site backups, no tape backups and the only full backups were on disk. Then the SAN glitched and both the data files and backups were corrupted. I&#8217;m probably preaching to the converted, but I don&#8217;t think there are [...]]]></description>
			<content:encoded><![CDATA[<p>Had a lovely situation this morning.</p>
<p>I can&#8217;t go into details, but essentially a database had no off-site backups, no tape backups and the only full backups were on disk. Then the SAN glitched and both the data files and backups were corrupted.</p>
<p>I&#8217;m probably preaching to the converted, but I don&#8217;t think there are many more important things on a production server than ensuring good backups.</p>
<p>However, having the backups is not enough. Can they be restored? If there&#8217;s a complete drive failure of all drives connected to a server, can the databases be recovered?</p>
<p>When the pawpaw hits the fan (as the local saying goes), that&#8217;s the only thing that matters.</p>
]]></content:encoded>
			<wfw:commentRss>http://sqlinthewild.co.za/index.php/2008/03/06/on-recoverability/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

