<?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>Home Of The Scary DBA</title>
	<atom:link href="http://www.scarydba.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.scarydba.com</link>
	<description>Intimidating Databases and Code</description>
	<lastBuildDate>Wed, 16 May 2012 13:50:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Don&#8217;t You Know Who I Am?</title>
		<link>http://www.scarydba.com/2012/05/16/dont-you-know-who-i-am/</link>
		<comments>http://www.scarydba.com/2012/05/16/dont-you-know-who-i-am/#comments</comments>
		<pubDate>Wed, 16 May 2012 13:50:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[professional association of sql server users]]></category>
		<category><![CDATA[speakers]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[sql saturday]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/05/16/dont-you-know-who-i-am/</guid>
		<description><![CDATA[I’m happy to say that for most of you out there, the answer to this question is “no.” That’s as it should be. I’m not anyone all that special. I present technical sessions at various events from local user group meetings to SQL Saturday’s to international events like the PASS Summit and 24 Hours of [...]]]></description>
			<content:encoded><![CDATA[<p>I’m happy to say that for most of you out there, the answer to this question is “no.” That’s as it should be. I’m not anyone all that special. I present technical sessions at various events from local user group meetings to SQL Saturday’s to international events like the PASS Summit and 24 Hours of PASS. Why? Not because the attendees know my name, that’s for sure. It’s because of a combination of at least two of these three things:</p>
<ol>
<li>The organizers might know my name or may know of my books or the fact that I’m working for a vendor that sponsors their event</li>
<li>I’ve submitted sessions that seem to be of interest to the people who might be attending the event being organized</li>
<li>I’ve got a track record of delivering decent, if not world-altering, presentations that people find useful.</li>
</ol>
<p>Let’s say you’re organizing a SQL Saturday event. And, let’s say that you want to get as many attendees as you possibly can. Is your best bet to find a bunch of people with MVP or MCM after their name? Or, should you focus on getting an interesting set of content from speakers that you know can deliver?</p>
<p>From what I’ve seen, it’s that second option that is your best bet. I’ve stood in front of people and started talking about a topic that I have a written a book about only to find that the entire room was not aware that I had written that book. They weren’t there for me. They were there for knowledge that I might be able to communicate to them. They were there for the topic, not the speaker. I’ve seen local speakers give presentations that were simply amazing, despite the fact that they didn’t have a book or weren’t blogging constantly. It’s the content and delivery, not the person delivering it. You’re going to know your local speakers as well as, or better than, any of the MVPs. Rely on your knowledge of these people and the fact that you’ve seen them present before.</p>
<p>This is something that I think way too many people overlook. Especially when you’re managing a SQL Saturday event, you need to build an interesting set of topics, not lure a bunch of MVPs to your event. Guaranteed, you’ll get an MVP or three. Don’t focus on that or worry about it. Instead, focus on your agenda. Build a good set of presentations, the kind that are going to be the most useful to your audience.</p>
<p>Don’t believe me? Check out these links to the front page of the PASS Summit <a href="http://www.sqlpass.org/summit/na2011" target="_blank">2011</a>, <a href="http://www.sqlpass.org/summit/na2010/" target="_blank">2010</a>, <a href="http://summit2009.sqlpass.org/" target="_blank">2009</a>. Note a couple of things. First, no headliners at all. No speakers are called out in any way except the people delivering the key notes. Second, there are Flickr &amp; Twitter streams in which anyone can be one the front page for a time. In short, the focus is on content and attendees.</p>
<p>Remember this when you’re setting up your event.</p>
<p>Oh, and don’t bother linking to this post. Everyone has my permission to copy and paste this and claim it as their own. You just have to include this disclaimer for everyone else to copy and paste this post as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/05/16/dont-you-know-who-i-am/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Which SELECT * Is Better?</title>
		<link>http://www.scarydba.com/2012/05/07/which-select-is-better/</link>
		<comments>http://www.scarydba.com/2012/05/07/which-select-is-better/#comments</comments>
		<pubDate>Mon, 07 May 2012 13:15:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[clustered index]]></category>
		<category><![CDATA[columnstore]]></category>
		<category><![CDATA[non-clustered index]]></category>
		<category><![CDATA[performance]]></category>
		<category><![CDATA[performance metrics]]></category>
		<category><![CDATA[performance tuning]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/05/07/which-select-is-better/</guid>
		<description><![CDATA[The short answer is, of course, none of them, but testing is the only way to be sure. I was asked, what happens when you run ‘SELECT *’ against a clustered index, a non-clustered index, and a columnstore index. The answer is somewhat dependent on whether or not you have a WHERE clause and whether [...]]]></description>
			<content:encoded><![CDATA[<p>The short answer is, of course, none of them, but testing is the only way to be sure.</p>
<p>I was asked, what happens when you run ‘SELECT *’ against a clustered index, a non-clustered index, and a columnstore index. The answer is somewhat dependent on whether or not you have a WHERE clause and whether or not the indexes are selective (well, the clustered &amp; non-clustered indexes, columnstore is a little different).</p>
<p>Let’s start with the simplest:</p>
<pre class="brush: sql; gutter: true">SELECT    *
  FROM    Production.ProductListPriceHistory AS plph;</pre>
<p>This query results in a clustered index scan and 5 logical reads. To do the same thing with a non-clustered index… well, we’ll have to cheat and it’ll look silly, but let’s be fair. Here’s my new index:</p>
<pre class="brush: sql; gutter: true">CREATE NONCLUSTERED INDEX TestIndex
  ON Production.ProductListPriceHistory
(ProductID,StartDate,EndDate,ListPrice,ModifiedDate);</pre>
<p>When I rerun the query it results in an index scan, non-clustered, with 5 logical reads. Granted, this is stupid. Instead, let’s do this. We’ll create a meaningful non-clustered index and then force it’s use:</p>
<pre class="brush: sql; gutter: true">CREATE NONCLUSTERED INDEX TestIndex
  ON Production.ProductListPriceHistory
(ListPrice);</pre>
<p>Then run this:</p>
<pre class="brush: sql; gutter: true">SELECT    *
  FROM    Production.ProductListPriceHistory AS plph
WITH (INDEX(TestIndex));</pre>
<p>Now that’s using a non-clustered index in a ‘SELECT *’ situation. It results in 794 logical reads and this execution plan:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/05/image.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.scarydba.com/wp-content/uploads/2012/05/image_thumb.png" alt="image" width="527" height="174" border="0" /></a></p>
<p>Clearly, this is not an improvement. Finally, let’s get rid of the non-clustered index and put this columnstore index in place:</p>
<pre class="brush: sql; gutter: true">CREATE NONCLUSTERED columnstore INDEX xtest
  ON production.ProductListPriceHistory
(productid,startdate,enddate,listprice,modifieddate);
GO</pre>
<p>Now when I run the ‘SELECT *’ query I have 37 reads and this execution plan:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/05/image1.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.scarydba.com/wp-content/uploads/2012/05/image_thumb1.png" alt="image" width="379" height="87" border="0" /></a></p>
<p>This means the columnstore index is being used, but, if you look at the properties, you’ll see that the execution mode on this one is Rows, which is not the preferred use you’ll want out of a columnstore index. You want to see the execution mode be Batch.</p>
<p>If we stopped here, the answer is simple, a clustered index scan is better. But what if we add filtering? Let’s modify the query to look like this:</p>
<pre class="brush: sql; gutter: true">SELECT    *
  FROM    Production.ProductListPriceHistory AS plph
WHERE    plph.ListPrice = 23.5481;</pre>
<p>Now, I’ll go back and set up the table so that it has just the clustered index, a non-clustered index, or the columnstore index. The results for the clustered index are identical. Since the column, ListPrice, is not part of the clustered key, a scan is necessary and the results are 5 reads and an execution time of about 1ms (the data is cached). The non-clustered index resulted in the same execution plan as before, but only 8 reads. But, the execution time was 42ms, so the added processing of getting the data put together from the key lookup was a little costly. Finally, the columnstore index results in 42 reads and an execution time of 4ms. The execution mode of the columnstore index was still Row.</p>
<p>What’s all this mean? Not much since you shouldn’t be using ‘SELECT *’ anyway, but the main takeaway I’d suggest is that columnstore indexes are not magic. They don’t replace traditional indexing. Further, if you’re going to use them, be sure that you’re really using them correctly. Just because you see the columnstore operator in the execution plan doesn’t mean you’re taking advantage of all the fantastic benefits they offer. Dive down into the properties and check the execution mode to ensure you’re getting a Batch execution. Then you’ll know that you’re benefiting from the columnstore index.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/05/07/which-select-is-better/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Changing DB_CHAIN Can Clear the Plan Cache</title>
		<link>http://www.scarydba.com/2012/04/30/changing-db_chain-can-clear-the-plan-cache/</link>
		<comments>http://www.scarydba.com/2012/04/30/changing-db_chain-can-clear-the-plan-cache/#comments</comments>
		<pubDate>Mon, 30 Apr 2012 13:15:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[database options]]></category>
		<category><![CDATA[plan cache]]></category>
		<category><![CDATA[t-sql]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/04/30/changing-db_chain-can-clear-the-plan-cache/</guid>
		<description><![CDATA[If you make changes to the settings of a database, it can cause the procedure cache to be cleared. Microsoft has documented changes that cause this for all procs within a database (scroll down to just above the examples). But guess what, if you change the DB_CHAINING option, it clears the cache too. Here’s a [...]]]></description>
			<content:encoded><![CDATA[<p>If you make changes to the settings of a database, it can cause the procedure cache to be cleared. <a href="http://technet.microsoft.com/en-us/library/ms174269.aspx" target="_blank">Microsoft has documented</a> changes that cause this for all procs within a database (scroll down to just above the examples). But guess what, if you change the DB_CHAINING option, it clears the cache too. Here’s a sample script to show it in action.</p>
<pre class="brush: sql; gutter: true">ALTER DATABASE Testing SET DB_CHAINING OFF;
GO

CREATE PROCEDURE x
AS
    SELECT    *
    FROM    test.dbo.A AS a2;
GO

CREATE PROCEDURE y
AS
    SELECT    *
    FROM    dbo.Table_1 AS t;
GO

EXEC dbo.x;

EXEC dbo.y;

SELECT    deqs.creation_time
FROM    sys.dm_exec_query_stats AS deqs
        CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE    dest.text LIKE &#039;CREATE PROCEDURE x%&#039;
        OR dest.text LIKE &#039;CREATE PROCEDURE y%&#039;;

ALTER DATABASE Testing SET DB_CHAINING ON;

SELECT    deqs.creation_time
FROM    sys.dm_exec_query_stats AS deqs
        CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
WHERE    dest.text LIKE &#039;CREATE PROCEDURE x%&#039;
        OR dest.text LIKE &#039;CREATE PROCEDURE y%&#039;;

ALTER DATABASE Testing SET DB_CHAINING OFF;</pre>
<p>The script is almost self-explanatory. I want to point out that I put in one cross-database query to imply the possibility of cross-database ownership or access, but also to show that regardless of what’s referenced, all queries from this database are flushed from cache.</p>
<p>The first of the simple DMO queries returns two rows, the second returns no rows because everything is out of the cache because of the change to the database. It’s a little thing, but since it wasn’t explicitly stated in the Microsoft documentation, I thought I’d toss this out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/04/30/changing-db_chain-can-clear-the-plan-cache/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AlwaysOn Failover Bug</title>
		<link>http://www.scarydba.com/2012/04/26/alwayson-failover-bug/</link>
		<comments>http://www.scarydba.com/2012/04/26/alwayson-failover-bug/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 13:50:37 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[connect]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/?p=2096</guid>
		<description><![CDATA[I just found a little bug in AlwaysOn. It’s actually not that big a deal, but it’s interesting. In a nutshell, if you have a table with an IDENTITY seed less than 1000, when you do a failover the table is reseeded to 1001. The steps to reproduce are posted on this Connect item. If [...]]]></description>
			<content:encoded><![CDATA[<p>I just found a little bug in AlwaysOn. It’s actually not that big a deal, but it’s interesting. In a nutshell, if you have a table with an IDENTITY seed less than 1000, when you do a failover the table is reseeded to 1001. The steps to reproduce are posted on <a href="https://connect.microsoft.com/SQLServer/feedback/details/739013/alwayson-failover-results-in-reseed-of-identity" target="_blank">this Connect item</a>. If you have feedback on this, please post it directly to the Connect item since I don’t think Microsoft reads my blog much.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/04/26/alwayson-failover-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comments on Acceptable Behavior</title>
		<link>http://www.scarydba.com/2012/04/23/comments-on-acceptable-behavior/</link>
		<comments>http://www.scarydba.com/2012/04/23/comments-on-acceptable-behavior/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 13:15:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[#sqlfamily]]></category>
		<category><![CDATA[behavior]]></category>
		<category><![CDATA[jerks]]></category>
		<category><![CDATA[MVP]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/04/23/comments-on-acceptable-behavior/</guid>
		<description><![CDATA[Here’s the situation. We’re absolutely falling down as men and professionals. Ladies, feel free to read on and comment, but I’m talking to the guys. This blog post has been percolating in my mind for quite some time, but a few new stories have brought it to the fore. The most recent was when I [...]]]></description>
			<content:encoded><![CDATA[<p>Here’s the situation. We’re absolutely falling down as men and professionals. Ladies, feel free to read on and comment, but I’m talking to the guys.</p>
<p>This blog post has been percolating in my mind for quite some time, but a few new stories have brought it to the fore. The most recent was when I heard that, in front of multiple other male MVPs, a female peer was propositioned using language that I wouldn’t condone when speaking to an animal, let alone a peer. And that’s the point, these women are peers. Yes, they happen to be female, but more importantly, they’re our peers. </p>
<p>And you know who I’m most upset with? No, not the individual who acted like a jerk. There’s always a few of those around. No, I’m upset with the MVPs who were present when it occurred and did nothing. Said nothing. Did nothing! Simple question for you lot. Are you men, or are you boys? If you’re men, you don’t let other men talk to your peers that way. Ever. It’s not acceptable. It’s not polite. Most importantly, it’s not professional. If you’re boys, please go home until you’ve decided to grow up.</p>
<p>I get it. We’re all consenting adults (except the boys, who have left) and we all have different levels of tolerance for different types of behavior. I know I’ve personally crossed lines that upset others and I’ve been called out on it (by men, and professionals, acting as such). Sooner or later everyone is going to cross a line somewhere. It happens. What I would expect is that we will stand up, like men, like professionals, and hold that person accountable for their actions. Then that person can adjust their behavior appropriately, issuing apologies as needed. And women aren’t gentle flowers that need protecting. Far from it. However, they are peers. They are our equals (probably, based on behaviors noted, superior to some of you). They should absolutely be treated like it.</p>
<p>I also understand that we’re going to be in places where alcohol may be consumed, and to excess (guilty again). This lowers inhibitions and changes behaviors. Once more, we’re all adults and if you don’t want to be around this behavior, don’t go. But once more, it’s entirely possible to go through your alcohol consumption without turning into a raging jerk. And, if someone turns into a raging jerk, the rest of us have to be ready to intervene when it’s clear it’s necessary. In the case I mention, and in others I’ve heard about, it was necessary. </p>
<p>And yeah, we may go to places intentionally to let our hair down in less than appropriate ways (once more, guilty). Usually these are very clearly marked and announced so you can’t go into them expecting a church social. It won’t be. But, you also can’t go into them acting like a raging jerk. </p>
<p>I was discussing this with others, because of other similar stories that came up, and we decided that the simplest way to explain this is using the <a href="http://en.wikipedia.org/wiki/Wil_Wheaton#Wheaton.27s_law" target="_blank">Wheaton Law</a> (possibly NSFW), which I had to look up. It’s very similar to the <a href="http://en.wikipedia.org/wiki/Golden_Rule" target="_blank">Golden Rule</a> (and yeah, that’s Wikipedia, cope), which I already knew. But I’ve supplied links to both so you can figure it out in case either of these is new to you. I mean come on guys, just because you’re away from your wives and you’re around fun, intelligent, beautiful women (of which we have more than our share in the SQL Server Community) doesn’t mean you start propositioning anything that moves. And if you really must do this, do it with some class and understand that when the lady says no, it ends that line of pursuit.</p>
<p>And don’t think this has gone unnoticed. I’m using the one general scenario because it was pointed out to me that MVPs are evidently not capable of policing themselves. If we don’t do it, it will be done for us and not in ways that any of us are going to appreciate.</p>
<p>I realize this is likely to be an unpopular post. I really don’t care. I’m more than a little ashamed to be associated with people who act that way towards women. Sorry. Don’t like it. Can’t abide it. Something must be said before things have to be done. I actually can’t believe I’ve had to write this down, but I’ve heard too many of these stories to stand quietly by any longer. </p>
<p>Let me reiterate. I’m not saying this because I think women are wilting flowers that need protection. Far from it. I know a few of the ladies from the SQL Family that will remove your family jewels and show you the side of them that you’ve never seen before. It’s not that I think they need protection, no. It’s that I think they shouldn’t have to put up with the jerky behavior. It’s that simple.</p>
<p>Jerks, you’re on notice. There are men, professional men, out there and they’re going to call you out on your behavior. Clean it up now. Guys, don’t let these jerks define us, ever.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/04/23/comments-on-acceptable-behavior/feed/</wfw:commentRss>
		<slash:comments>45</slash:comments>
		</item>
		<item>
		<title>SQL Server Log Backups</title>
		<link>http://www.scarydba.com/2012/04/02/sql-server-log-backups/</link>
		<comments>http://www.scarydba.com/2012/04/02/sql-server-log-backups/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 12:38:02 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[full recovery]]></category>
		<category><![CDATA[log backup]]></category>
		<category><![CDATA[recovery plan]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/?p=2088</guid>
		<description><![CDATA[While presenting a session on Common Backup Problems both at SQL Saturday in Orange County and at SQL Connections in Las Vegas, questions came up regarding whether, when, and how your databases should be configured in FULL recovery mode and what that means for your recovery plans. To boil the questions down to as simple [...]]]></description>
			<content:encoded><![CDATA[<p>While presenting a session on Common Backup Problems both at <a href="http://www.sqlsaturday.com/120/eventhome.aspx" target="_blank">SQL Saturday in Orange County</a> and at <a href="http://www.devconnections.com/shows/sp2012/default.aspx?s=185" target="_blank">SQL Connections in Las Vegas</a>, questions came up regarding whether, when, and how your databases should be configured in FULL recovery mode and what that means for your recovery plans.</p>
<p>To boil the questions down to as simple a single statement as possible:</p>
<blockquote><p>Should your database be in FULL recovery mode at all times which requires you to run log backups on a regular schedule?</p>
</blockquote>
<p>The same question came up while Brad McGehee(<a href="http://www.bradmcgehee.com/" target="_blank">blog</a>|<a href="http://www.twitter.com/bradmcgehee" target="_blank">twitter</a>) was presenting a session on using the settings on your SQL Server instance and your database to ensure you got proper performance. We both answered the question the same way, but our emphasis was slightly different.</p>
<p>Brad’s answer was that, yes, you should, by default, set your databases to FULL recovery in order to plan for the possibility of a point in time recovery. I agree with him. </p>
<p>But, my answer was different. What I said was, you need make a choice here. Yes, you should have your production databases in FULL recovery in order to arrive at the best possible recovery process. However, that means you’re dedicating yourself to maintaining log backups. If, for whatever reason, you can’t maintain log backups, then you should set your recovery to SIMPLE. </p>
<p>My point was not to disagree with Brad, or, more accurately, I don’t think he disagreed with me (since he went on 2nd). Rather, I’m trying to tell you that you must make that choice. You need to either commit to the process of setting up an appropriate recovery process for your production systems, which, in the majority of circumstances should include log backups, or, you need to admit that you can only recover your databases to the last FULL or DIFFERENTIAL backup and make that part of your documented plan, setting your databases to SIMPLE. What you can’t do, at least not any more <a href="http://msdn.microsoft.com/en-us/library/ms186865(v=sql.100).aspx" target="_blank">since SQL Server 2008 was released</a>, is rely on BACKUP LOG WITH NO_LOG or WITH TRUNCATE_ONLY as a means for leaving your database in FULL recovery, but also throwing away the log data (and I’ve never understood why people do that except through ignorance of how Log backups &amp; recovery works). </p>
<p>Now, you have to commit. I believe you should set up the Log backups, but if you don’t, fine, turn off FULL recovery. Just do so with the complete knowledge of what that means.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/04/02/sql-server-log-backups/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Execution Plan for a User Defined Function</title>
		<link>http://www.scarydba.com/2012/03/26/execution-plan-for-a-user-defined-function/</link>
		<comments>http://www.scarydba.com/2012/03/26/execution-plan-for-a-user-defined-function/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 12:45:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[SQL Server 2008]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[TSQL]]></category>
		<category><![CDATA[dynamic management object]]></category>
		<category><![CDATA[execution plan]]></category>
		<category><![CDATA[execution plan operators]]></category>
		<category><![CDATA[multi-statement udf]]></category>
		<category><![CDATA[udf]]></category>
		<category><![CDATA[user defined function]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/03/26/execution-plan-for-a-user-defined-function/</guid>
		<description><![CDATA[When you execute a multi-statement user-defined function you may see an execution plan that looks something like this: It appears as if the cost of the UDF is free. This is especially true if you use the UDF in a query with other objects, such as joining it to actual tables. Since the optimizer always [...]]]></description>
			<content:encoded><![CDATA[<p>When you execute a multi-statement user-defined function you may see an execution plan that looks something like this:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image3.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb3.png" alt="image" width="244" height="91" border="0" /></a></p>
<p>It appears as if the cost of the UDF is free. This is especially true if you use the UDF in a query with other objects, such as joining it to actual tables. Since the optimizer always assumes a multi-statement UDF has a single row for statistics estimates, it&#8217; frequently displays a low cost.</p>
<p>But you know that there’s more going on there, right? It’s a multi-statement UDF because it’s doing a lot of work, but that is not reflected in the execution plan.. or is it?</p>
<p>What if we went after the cache? Let’s run this little query:</p>
<p>SELECT  deqp.query_plan,<br />
dest.text,<br />
SUBSTRING(dest.text, (deqs.statement_start_offset / 2) + 1,<br />
(deqs.statement_end_offset &#8211; deqs.statement_start_offset)<br />
/ 2 + 1) AS actualstatement<br />
FROM    sys.dm_exec_query_stats AS deqs<br />
CROSS APPLY sys.dm_exec_query_plan(deqs.plan_handle) AS deqp<br />
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest<br />
WHERE   deqp.objectid = OBJECT_ID(&#8216;dbo.ufnGetContactInformation&#8217;);</p>
<p>This query doesn’t do anything really fancy. I’m using the sys.dm_exec_query_stats which holds aggregated performance metrics for any query currently in cache because it has the plan_handle that lets me look up execution plans in sys.dm_exec_query_plan. It just so happens that you also get the objectid there in the plan so we can look for the specific plan that corresponds to our UDF (I’m using an example from AdventureWorks2008R2). The results from the query look like this:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image4.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb4.png" alt="image" width="244" height="47" border="0" /></a></p>
<p>Each row represents a statement that has been executed from the UDF. There’s just a single plan for the UDF, and it looks like this:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image5.png"><img style="background-image: none; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb5.png" alt="image" width="213" height="244" border="0" /></a></p>
<p>Without even drilling down to all the details of what’s going on in the plan, I think we can agree, that this UDF is not zero cost, but may in fact be extremely expensive depending on what’s going on inside that execution plan.</p>
<p>Why is this useful? Because it lets you look behind that simplistic… lie, that is shown as a plan for the execution of a UDF to see what the UDF is actually doing. This may make it possible to improve the performance of the UDF since you’ll be able to identify missing indexes and other information thanks to your direct access to what’s going on inside the UDF.</p>
<p>I had demoed this during my 24 Hours of PASS presentation and was asked to put the code up on my blog, so here you go. I hope it&#8217; proves helpful.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/03/26/execution-plan-for-a-user-defined-function/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>TDE and Compression</title>
		<link>http://www.scarydba.com/2012/03/19/tde-and-compression/</link>
		<comments>http://www.scarydba.com/2012/03/19/tde-and-compression/#comments</comments>
		<pubDate>Mon, 19 Mar 2012 12:56:31 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/?p=2077</guid>
		<description><![CDATA[I knew that enabling TDE would cause the information stored within to, effectively, be randomized, which means it would seriously impact the ability for backup compression to work well. It even says this in Books Online: Encrypted data compresses significantly less than equivalent unencrypted data. If TDE is used to encrypt a database, backup compression [...]]]></description>
			<content:encoded><![CDATA[<p>I knew that enabling TDE would cause the information stored within to, effectively, be randomized, which means it would seriously impact the ability for backup compression to work well. It even says this in <a href="http://msdn.microsoft.com/en-us/library/bb934049.aspx" target="_blank">Books Online</a>:</p>
<blockquote><p>Encrypted data compresses significantly less than equivalent unencrypted data. If TDE is used to encrypt a database, backup compression will not be able to significantly compress the backup storage. Therefore, using TDE and backup compression together is not recommended.</p>
</blockquote>
<p>I took that completely at face value and always figured it meant I would only get 5-10% compression or something instead of the higher rates available through backup compression (or the much, much higher rates available through 3rd party compression). Imagine my surprise when I tested this on a 20gb database. Not only did I get no compression, as in zero, but the size of the backup went up slightly.</p>
<p>So, when you go to enable TDE, think about what this means for your backup storage. If you’re counting on compression, you might be in trouble.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/03/19/tde-and-compression/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SQL Server 2012 AlwaysOn &amp; A Thorough Setup</title>
		<link>http://www.scarydba.com/2012/03/12/sql-server-2012-alwayson-a-thorough-setup/</link>
		<comments>http://www.scarydba.com/2012/03/12/sql-server-2012-alwayson-a-thorough-setup/#comments</comments>
		<pubDate>Mon, 12 Mar 2012 12:45:00 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[AlwaysOn]]></category>
		<category><![CDATA[High Availability]]></category>
		<category><![CDATA[Network Issues]]></category>
		<category><![CDATA[Read The Error Message]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/2012/03/12/sql-server-2012-alwayson-a-thorough-setup/</guid>
		<description><![CDATA[It’s surprisingly easy to set up the new AlwaysOn features. I’ve done it on VMs running on my laptop, from scratch, three times in the last few weeks. It’s easy because there are a set of validations that your run for the cluster and for the AlwaysOn setup that ensure you’re going to get a [...]]]></description>
			<content:encoded><![CDATA[<p>It’s surprisingly easy to set up the new AlwaysOn features. I’ve done it on VMs running on my laptop, from scratch, three times in the last few weeks. It’s easy because there are a set of validations that your run for the cluster and for the AlwaysOn setup that ensure you’re going to get a successful install… or do they?</p>
<p>I hit a situation where it didn’t work correctly, so I thought I’d share it in case others ran into it.</p>
<p>The setup is straight forward. I have network, contoso (yes, I’m using Microsoft training &amp; documentation, it’s a beta, but you should see it available soon), with a domain controller and five servers all in a failover cluster. They passed the cluster test, so all five are hooked in. I went to use the Availability Group Wizard to set things up. I chose a database with a&#160; full backup in Full Recovery mode. I added a second server to act as the secondary in the Failover Group. I chose a share where the backup was kept and was accessible to the other server (I even checked this). Then I ran the validations:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb.png" width="644" height="236" /></a></p>
<p>Which came back all green except for the warning about the listener configuration (which, you don’t need to set up an Availability Group, just to access one from an app, seemlessly).</p>
<p>I checked the summary and then built my group, which took WAY too long, and was presented with this:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image1.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb1.png" width="644" height="380" /></a></p>
<p>What the heck? So I took a look at the error:</p>
<p><a href="http://www.scarydba.com/wp-content/uploads/2012/03/image2.png"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://www.scarydba.com/wp-content/uploads/2012/03/image_thumb2.png" width="644" height="258" /></a></p>
<p>Connection not active? Yes it sure is. I went round and round through this. Seriously. First, I found out I had a database in 2008R2 compatibility mode (and how funny is that to be saying at last). Fixed it. No joy. Took a new backup (dummy). No joy. Revalidated every possible check from this server. Nothing.</p>
<p>In desperation I went to another server and tried setting up AlwaysOn between it and a neighbor. It worked… What. The. ****?</p>
<p>Then, I went back and reread the error message (always a good thing). “The CONNNECTION to the primary replica is not active” Well, that’s how I read it the second time. So I tried connecting to the primary from the secondary, just through SSMS. No connection. I went back to the primary &amp; double-checked, yes, it could connect to all four of it’s brother &amp; sister servers. Checked each of them for connectivity back… nothing. I had a network problem that I didn’t realize was there.</p>
<p>So, moral of the story, just because you’ve run the tests that MS provides for AlwaysOn doesn’t mean you won’t run into an issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/03/12/sql-server-2012-alwayson-a-thorough-setup/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s Talk</title>
		<link>http://www.scarydba.com/2012/03/08/lets-talk/</link>
		<comments>http://www.scarydba.com/2012/03/08/lets-talk/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 15:57:24 +0000</pubDate>
		<dc:creator>Grant Fritchey</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[Professional Development]]></category>
		<category><![CDATA[SQL Server 2012]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[presenting]]></category>
		<category><![CDATA[Speaking]]></category>
		<category><![CDATA[talk to me]]></category>

		<guid isPermaLink="false">http://www.scarydba.com/?p=2068</guid>
		<description><![CDATA[I’m travelling to several upcoming events and I’d love to sit down and talk with you. Yes, I get it, most of these events you’re going to see the sessions, but you really should plan on networking too. Here’s your chance to get started on that: Southern New England SQL Server Users Group, East Greenwich,RI [...]]]></description>
			<content:encoded><![CDATA[<p>I’m travelling to several upcoming events and I’d love to sit down and talk with you. Yes, I get it, most of these events you’re going to see the sessions, but you really should plan on networking too. Here’s your chance to get started on that:</p>
<p><a href="http://snessug.org/" target="_blank">Southern New England SQL Server Users Group</a>, East Greenwich,RI – 3/14/2012:     <br />TSQL Deployment and Continuous Integration Best Practices</p>
<p><a href="http://www.sqlsaturday.com/120/eventhome.aspx" target="_blank">SQL Saturday 120, Orange County</a> &#8211; 3/24/2012:    <br />I’m presenting two times here. They’re both presentations that I’m working up for Connections.    <br />Common Backup Problems and How To Deal With Them    <br />TSQL Deployment and Continuous Integration Best Practices</p>
<p><a href="http://devconnections.com/shows/sp2012/default.aspx?s=185" target="_blank">SQL Connections:Las Vegas</a> 3/26 – 3/29/2012:    <br />I get it. You don’t go to Vegas to network. That doesn’t mean you can’t still do that too. I’m presenting three sessions.    <br />Top Tips for Writing Better TSQL    <br />Common Backup Problems and How To Deal With Them    <br />TSQL Deployment and Continuous Integration Best Practices</p>
<p><a href="http://www.nesql.org/Home/tabid/75/ModuleID/402/ItemID/54/mctl/EventDetails/Default.aspx" target="_blank">New England SQL Server Users Group</a> – 4/12/2012:    <br />Common Backup Problems and How To Deal With Them</p>
<p><a href="http://www.sqlsaturday.com/111/eventhome.aspx" target="_blank">SQL Saturday 111</a>, Atlanta – 4/14/2012:    <br />Execution Plans, a Deep Dive    <br />Common Backup Problems and How to Deal With Them</p>
<p>In addition to these networking opportunities, I’m also speaking online at:</p>
<p><a href="http://www.sqllunch.co.uk/" target="_blank">SQL Lunch UK</a> – 3/13/2012:     <br />Deadlocks, How to Identify Them and What to Do About Them</p>
<p><a href="http://www.sqlpass.org/24hours/spring2012/" target="_blank">24 Hours Of PASS</a> – 3/24/2012:    <br />What to Look For in SQL Server 2012 Execution Plans</p>
<p>I’ve got more stuff coming in May, June and July (including SQL in the City) and I’ll post that as we get closer. </p>
<p>Seriously, please, let’s talk.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.scarydba.com/2012/03/08/lets-talk/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.124 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-17 18:30:25 -->

