<?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>codegumbo &#187; SQL Server</title>
	<atom:link href="http://codegumbo.com/index.php/category/development/sql-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://codegumbo.com</link>
	<description>Laissez Les Bon Code Roulez!</description>
	<lastBuildDate>Fri, 03 Feb 2012 00:43:59 +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>#msteched Columnstore indexes unveiled&#8211;DBI312</title>
		<link>http://codegumbo.com/index.php/2011/05/17/msteched-columnstore-indexes-unveileddbi312/</link>
		<comments>http://codegumbo.com/index.php/2011/05/17/msteched-columnstore-indexes-unveileddbi312/#comments</comments>
		<pubDate>Tue, 17 May 2011 13:41:36 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2011/05/17/msteched-columnstore-indexes-unveileddbi312/</guid>
		<description><![CDATA[Live blogging again; hope you find my notes useful (scattered though they are).&#160; I’ve been waiting on this session because it’s a very specific area of interest.&#160; I work a lot with VLDB’s, and performance is always a concern; claims are that Denali’s columnstore may boost performance of certain queries hundred-fold.&#160; Let’s see how they [...]]]></description>
			<content:encoded><![CDATA[<p>Live blogging again; hope you find my notes useful (scattered though they are).&#160; I’ve been waiting on this session because it’s a very specific area of interest.&#160; I work a lot with VLDB’s, and performance is always a concern; claims are that Denali’s columnstore may boost performance of certain queries hundred-fold.&#160; Let’s see how they work, and I’m hoping I can convince my boss to set up a test bed to try this out.</p>
<p>Presenter is Eric N Hanson from Microsoft (<a href="http://twitter.com/#!/enh_sqlserver" target="_blank">Twitter</a>).&#160; </p>
<p>We start off with a story; I like story-time.&#160; Actually, it’s a very effective way to break out user cases.</p>
<p>Buzzphrase for Columnstore: “Enabling interaction with data”.&#160; Supposed to be super efficient, and get large amounts of data back from SQL Server Denali.&#160; Internal project name is Apollo; columnstore is only part of the picture.</p>
<p>Area of focus is BI &amp; DW: load large amounts of data, high-read, incremental loads.&#160; Partitioning is mandatory for this feature.</p>
<p>Curious as to why the examples join tables in the WHERE clause, and not the more accepted syntax of JOIN.</p>
<p>K, here comes the magic: example uses a Fact Table with 100 million rows in it.&#160; Clustered on a date column, and a columnstore index.&#160; Clustered index is still B-TREE; columnstore indexes are nonclustered.</p>
<p>Running duplicate queries; using index hint to force optimizer to use the clustered index in one example.&#160; Wow; 100,000,000 rows of data aggregated in a second on a two-year old laptop.&#160; 50x speedup on this particular hardware.&#160; According to presenter: “this is the biggest enhancement to SQL Server since we bought the code from Sybase&quot;.</p>
<p>And here’s the meat and potatoes; how does this work?&#160; Vertical partitioning stores each column in a separate page.&#160; Columnstore is based on the same code as PowerPivot and the BI engine;&#160; Vertipaq if you want to do more reading on this.&#160; Columnstore data is highly compressed, so smaller footprint to read from disk and can be stored in main memory.</p>
<p>New query execution plan: batch processing.&#160; “the edsel is the way of the future”.&#160; Actually, the idea is that batches of vectors are stored in query plan; highly efficient data representation.&#160; We can also scale to more cores: tests are showing linear acceleration up to 32 cores.</p>
<p>Instead of storing data as a page, data is stored as a column segment which represents about 1,000,000 rows.</p>
<p>Questions have begun; some questions are good, but this is a 300 level session, folks.&#160; If you don’t understand basic SQL syntax (like how to create an index), this may not be the session for you.&#160; Great question about the relevance of traditional indexes after this is unveiled, and Hanson’s response: in most Decision Support Applications, columnstore is the way to go particularly for scans.</p>
<p>Some index hints for choosing the columnstore or ignoring it:</p>
<p>WITH (index(index_name))</p>
<p>OPTION (ignore_nonclustered_columnstore_index) &lt;—use for bad plan selection if necessary.</p>
<p>Same traditional rules for index hints: trust the optimizer first, rewrite second, and then use hints last.</p>
<p>A couple of new icons for query execution plans: columnstore scan, and batch hash table processing.&#160; Each execution operator now operates in either batch mode or row mode; batch mode is what you want for speed.&#160; </p>
<p>New term of interest: dictionary.&#160; A dictionary is storage for unique values with a lookup so that a column can stores highly compressed information.</p>
<p>Most things just work with SQL Server; Backup and Restore, Mirroring, SSMS, etc.</p>
<p>Lots of datatypes don’t work with column store: long decimals, binary, BLOB, uniqueidentifier, long datetimes, CLR,&#160; (n)varchar(max).</p>
<p>query performance restrictions: outer joins, Unions; Stick with Inner Joins, Star Joins (need to look this one up) Aggregation.&#160; About to show a query which doesn’t benefit from batch processing.&#160; Essence is below:</p>
<p>SELECT t.ID, COUNT(t2.ID)   <br />FROM t LEFT JOIN t2 ON t.ID=t2.ID    <br />GROUP BY t.ID</p>
<p>Left Join knocks it out of batch processing; need to rewrite as an INNER JOIN, but note that you lose the NULL values, so you have to use a CTE; need to get slides for his sample, but you do an INNER JOIN in the CTE, and then do an OUTER JOIN.&#160; </p>
<p>WITH CTE( INNER JOIN)   <br />SELECT blah    <br />FROM t OUTER JOIN CTE ON t.ID yada yada.</p>
<p>Adding data to columnstore; basic methods:</p>
<p>1.&#160; Drop and re-add the index before load.&#160; Expensive, but works well with traditional daily builds</p>
<p>2.&#160; Partition switching.&#160; Sweet spot needs to be tested, but easy one is the hour.&#160; NOLOCK queries pre-empt the ability to do paritioned queries.&#160; Need to read up on this, but may be fixed in future version</p>
<p>3&#160; trickle load can be done, but needs to be tested.</p>
<p>Very awesome; I cannot wait until this is actually released in CTP 3, so I can play around with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2011/05/17/msteched-columnstore-indexes-unveileddbi312/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>#msteched &#8220;Juneau&#8221; preview</title>
		<link>http://codegumbo.com/index.php/2011/05/16/msteched-juneau-preview/</link>
		<comments>http://codegumbo.com/index.php/2011/05/16/msteched-juneau-preview/#comments</comments>
		<pubDate>Mon, 16 May 2011 20:03:17 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2011/05/16/msteched-juneau-preview/</guid>
		<description><![CDATA[Sitting in the Database Dev session at Tech Ed, taking a look at “Juneau”, the new development suite for SQL Server.&#160; I can’t wait to see if this thing slices and dices data like a Ronco food processor.&#160; Again, live blogging, so please excuse the scattered thoughts, poor spelling, and other bad habits below. Database [...]]]></description>
			<content:encoded><![CDATA[<p>Sitting in the Database Dev session at Tech Ed, taking a look at “Juneau”, the new development suite for SQL Server.&#160; I can’t wait to see if this thing slices and dices data like a Ronco food processor.&#160; Again, live blogging, so please excuse the scattered thoughts, poor spelling, and other bad habits below.</p>
<p>Database development is hard.&#160; I’d love to use that sometimes when my boss asks me why something is running behind schedule.&#160; </p>
<p>Great question!&#160; Where does the definition of the database live if most of your code is built on ALTER scripts?</p>
<p>We should work declaratively, not scripted; devs write CREATE statement, and let the tools manage the change statements.</p>
<p>Demos forthcoming…</p>
<p>&#160;</p>
<p>Connected development; working directly with the database server.&#160; Much like SSMS, but it’s obviously the VS shell instead.&#160; Operation is very similar to SSMS in that you build and execute queries inside of the shell; I wonder if execution plans work.</p>
<p>Table designer: uh-oh.&#160; Not sure if this is a good idea.&#160; However, the tools do drift detection before building an active script.</p>
<p>Side note to Microsoft presenters: sometimes the patter works, but only when it’s natural.&#160; Usually, it feels scripted, which makes it clunky instead of funny.</p>
<p>&#160;</p>
<p>Offline Development: Import database into a project, to build a model from the database.&#160; Declarative code is the keyword.&#160; Left-side versus right-side development; idea is that information is arranged depending on the perspective from which you are accustomed.&#160; DBA’s will see the traditional database hierarchy; developers will see the namespaces.</p>
<p>Table designer preview again; nice thing is that it is generating scripts on the fly. </p>
<p>SSTD is deployed to a new lightweight test-and-debug single user instance on your desktop.&#160; Cool stuff; no need to deploy to a test server; it’s there already.</p>
<p>Ughhhhh; live demos are painful.&#160; I’m going to remember to NOT DO THAT EVER AGAIN when I present.&#160; </p>
<p>Yay!!! Execution plans are there!!!!&#160; SWEET.</p>
<p>Interesting way to handle connected and disconnected development.&#160; Since you are building CREATE statements, you can’t run them in a connected sense; execute fails.&#160; But what happens when you run it and are building a new object?&#160; Will it execute?</p>
<p>OMG!!!!!!!! THEY ARE SHOWING A STORED PROCEDURE WITH A F’ING WHILE LOOP IN IT!!!!! I can’t believe that one slipped by.</p>
<p>Cooling off; I totally zoned out on the last view steps.&#160; Lemme calm down and move on to the next one.</p>
<p>&#160;</p>
<p>Publish to SQL Azure: More accurately, the project can be targeted to various editions, including Azure.</p>
<p>Nice feature to work online and offline.&#160; Not much else to say; the tool changes the model to fit the deployment target.</p>
<p>&#160;</p>
<p>SSMS is NOT going away, but the majority of the development functionality will be replicated in Visual Studio. Both will have Server Explorers and query windows, but SSMS will still ship as a part of the client tools for SQL Server.</p>
<p>Schema comparison tools still are lackluster compared to Red Gate, but they seem to have improved a little since I last remember them.&#160; Not really much new here compared to the database projects of 2010 and 2008, but it looks like there has been some thought about best practices.</p>
<p>Overall, a good presentation, but I still think there’s a lot left to do.</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2011/05/16/msteched-juneau-preview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>much delayed #sqlsat70 write-up</title>
		<link>http://codegumbo.com/index.php/2011/03/28/much-delayed-sqlsat70-write-up/</link>
		<comments>http://codegumbo.com/index.php/2011/03/28/much-delayed-sqlsat70-write-up/#comments</comments>
		<pubDate>Mon, 28 Mar 2011 19:40:08 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2011/03/28/much-delayed-sqlsat70-write-up/</guid>
		<description><![CDATA[This write-up will be brief and to the point: SQL Saturday 70 rocked.&#160; K. Brian Kelley (Blog&#124;Twitter) and his team put together a great event (again), and it was a lot of fun catching up with so many SQL people.&#160; Unfortunately, I had a rather severe sinus infection which kept me from really enjoying the [...]]]></description>
			<content:encoded><![CDATA[<p>This write-up will be brief and to the point: <a href="http://www.sqlsaturday.com/70/eventhome.aspx" target="_blank">SQL Saturday 70</a> rocked.&#160; K. Brian Kelley (<a href="http://www.sqlservercentral.com/blogs/brian_kelley/" target="_blank">Blog</a>|<a href="twitter.com/kbriankelley" target="_blank">Twitter</a>) and his team put together a great event (again), and it was a lot of fun catching up with so many SQL people.&#160; Unfortunately, I had a rather severe sinus infection which kept me from really enjoying the event (in fact, I left after my sessions), but I did have a good time.</p>
<p>My sessions went very well; I had small crowds, but they were very involved.&#160; I seem to keep picking esoteric topics (Data Architecture and XQuery), but the beauty of that is that I learn something new every time I start researching the subject.&#160; One thing that stood out for me is that even though I pitched the event as an Intermediate event, I still had a lot of foundational material to cover.&#160; I need to keep that in mind for future versions of my technical presentations.</p>
<p>General notes about the event: I have no complaints.&#160; The space was wonderful, the speaker room was more than adequate, and the food was great.&#160; The only thing that I think was missed was the same sin I’ve been guilty of at our AtlantaMDF events; the hosting organization wasn’t promoted enough.&#160; We get so caught up in making sure the event flows smoothly that I think we forget to tout the monthly events enough.</p>
<p>Anyway, it was a great show.&#160; If you attended my presentations, thank you; I hope you learned something.&#160; The slides are available at the links below:</p>
<p>Data Architect: <a title="http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3754" href="http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3754">http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3754</a></p>
<p>XQuery: <a title="http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3755" href="http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3755">http://www.sqlsaturday.com/viewsession.aspx?sat=70&amp;sessionid=3755</a></p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2011/03/28/much-delayed-sqlsat70-write-up/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>#sqlsat35 looking ahead to the weekend</title>
		<link>http://codegumbo.com/index.php/2010/05/21/looking-ahead-to-the-weekend/</link>
		<comments>http://codegumbo.com/index.php/2010/05/21/looking-ahead-to-the-weekend/#comments</comments>
		<pubDate>Fri, 21 May 2010 01:20:46 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[Blogging is FUN!]]></category>
		<category><![CDATA[Conferences]]></category>
		<category><![CDATA[PASS]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[The Social Web]]></category>

		<guid isPermaLink="false">http://codegumbo.com/?p=418</guid>
		<description><![CDATA[This weekend I&#8217;ll be traveling to the DFW metropolitan area to attend SQLSaturday #35; I&#8217;m very excited about it.  I didn&#8217;t know if I&#8217;d be able to attend this weekend (had to trade kid time with the ex-wife), so I missed the call for speakers.  I am looking forward to actually attending sessions and bumping [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I&#8217;ll be traveling to the DFW metropolitan area to attend <a href="http://www.sqlsaturday.com/35/eventhome.aspx" target="_blank">SQLSaturday #35</a>; I&#8217;m very excited about it.  I didn&#8217;t know if I&#8217;d be able to attend this weekend (had to trade kid time with the ex-wife), so I missed the call for speakers.  I am looking forward to actually attending sessions and bumping into some friends.   If you&#8217;re there, look me up; I&#8217;ll be wearing my SQLSaturday #41 t-shirt (<a href="http://codegumbo.com/index.php/2010/05/03/sqlsaturday-41-wrap-up-lessons-learned-from-atlanta-april-24-2010/" target="_blank">see this link for a sample</a>).</p>
<p>I&#8217;ll be packing a couple of presentations (just in case they have an opening): the <a href="http://www.atlantamdf.com/Presentations/AtlantaMDF_110909_The_Social_DBA.ppt" target="_blank">Social DBA</a> and my latest discussion on<a href="http://appdev.sqlpass.org/LinkClick.aspx?fileticket=L-j6Laya5A4%3d&amp;tabid=2005" target="_blank"> XML in SQL Server 2008</a>.  I was planning on submitting both of them to PASS Summit this year, but I feel a little guilty about the Social DBA one given that I&#8217;ve completely slacked off over the last few months.  I keep thinking I&#8217;m going to get back on the wagon, but life has been flying by much too fast these days.</p>
<p>Speaking of friends, Dallas is kind of like an old home to me; I grew up in Louisiana, and many of my high school and college buddies wound up in the big D after graduation.  I&#8217;m looking forward to crashing on a few couches, having a few beers, and hearing what happened over the last 20 years or so.</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2010/05/21/looking-ahead-to-the-weekend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Speaking today: PASS AppDev Virtual Chapter</title>
		<link>http://codegumbo.com/index.php/2010/05/11/speaking-today-pass-appdev-virtual-chapter/</link>
		<comments>http://codegumbo.com/index.php/2010/05/11/speaking-today-pass-appdev-virtual-chapter/#comments</comments>
		<pubDate>Tue, 11 May 2010 14:10:30 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[PASS]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://codegumbo.com/?p=414</guid>
		<description><![CDATA[I know it&#8217;s short notice, but to be honest, I totally forgot about this until a couple of weeks ago.  I&#8217;ll be presenting today at noon eastern on a LiveMeeting for the Application Developers Virtual Chapter of PASS.  Deets below: &#8220;You Got XML In My Database? What&#8217;s Up With That?&#8221; May 11th 12:00 PM EDT (GMT [...]]]></description>
			<content:encoded><![CDATA[<p>I know it&#8217;s short notice, but to be honest, I totally forgot about this until a couple of weeks ago.  I&#8217;ll be presenting today at noon eastern on a LiveMeeting for the Application <a href="http://appdev.sqlpass.org" target="_blank">Developers Virtual Chapter of PASS</a>.  Deets below:</p>
<p><strong>&#8220;You Got XML In My Database? What&#8217;s Up With That?&#8221;</strong><br />
<strong>May 11th 12:00 PM EDT (GMT -4)</strong><br />
<a href="http://appdev.sqlpass.org/LinkClick.aspx?fileticket=FN4vpQsMRo8%3d&amp;tabid=2003">Add to Calendar</a><br />
<strong>Presenter: Stuart Ainsworth</strong></p>
<p>A brief presentation exploring the marriage of XML and relational databases, including when it works and when it doesn&#8217;t. Coverage will include various use case scenarios, and some tips on how to improve performance using design techniques.</p>
<p><strong>Stuart Ainsworth</strong></p>
<p>Stuart R Ainsworth, MA, MEd is a Database Architect working in the realm of Financial Information Security; over the last 15 years, he&#8217;s worked as a Research Analyst, a report writer, a DBA, a programmer, and a public speaking professor. He&#8217;s one of the chapter leaders for AtlantaMDF, the Atlanta chapter of PASS. A master of air guitar, he has yet to understand the point of Rock Band (&#8220;You push buttons? What&#8217;s that all about?&#8221;).</p>
<p><strong>How do I view the presentation?<br />
</strong>Attendee URL:  <a href="https://www.livemeeting.com/cc/usergroups/join?id=4ZN5ST&amp;role=attend"><span style="text-decoration: underline;"><span style="color: #0000ff;">Live Meeting link</span></span></a></p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2010/05/11/speaking-today-pass-appdev-virtual-chapter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YAY!  Somebody likes me&#8230;</title>
		<link>http://codegumbo.com/index.php/2009/10/14/yay-somebody-likes-me/</link>
		<comments>http://codegumbo.com/index.php/2009/10/14/yay-somebody-likes-me/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 02:56:59 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2009/10/14/yay-somebody-likes-me/</guid>
		<description><![CDATA[I just got the email today; Red Gate friended me.&#160; Or, rather, I am now a Friend of Red Gate.&#160; What does this mean?&#160; I try to think of it kind of like a NASCAR patch; I now have a perpetual sponsor for all of my various presentations in the SQL community.&#160;&#160; I don’t know [...]]]></description>
			<content:encoded><![CDATA[<p><img style="display: inline; margin-left: 0px; margin-right: 0px" align="left" src="http://www.red-gate.com/images/friends_of_rg_logo.gif"> </p>
<p>I just got the email today; Red Gate friended me.&nbsp; Or, rather, I am now a <a href="http://www.red-gate.com/about/community_relations/friends_of_RG.htm" target="_blank">Friend of Red Gate</a>.&nbsp; What does this mean?&nbsp; I try to think of it kind of like a NASCAR patch; I now have a perpetual sponsor for all of my various presentations in the SQL community.&nbsp;&nbsp; I don’t know what else to say other than &#8220;THANK YOU!”</p>
<p>Seriously, I love Red Gate’s products, and have been a big fan of theirs for a long time.&nbsp; Their <a href="http://www.red-gate.com/products/SQL_Compare/index.htm" target="_blank">SQL Compare</a> product just works, and it works well (unlike the sometimes-challenging implementation in Visual Studio’s Database Developer).&nbsp;&nbsp; I bought <a href="http://www.red-gate.com/products/SQL_Prompt/index.htm" target="_blank">SQL Prompt</a> with my own money because I saw it as a major time saver. </p>
<p>I’m very jazzed about this.</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2009/10/14/yay-somebody-likes-me/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Building ranges using numbers</title>
		<link>http://codegumbo.com/index.php/2009/09/27/building-ranges-using-numbers/</link>
		<comments>http://codegumbo.com/index.php/2009/09/27/building-ranges-using-numbers/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 21:34:37 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2009/09/27/building-ranges-using-numbers/</guid>
		<description><![CDATA[A while back, I posted a solution to a problem I was facing where I needed to generate a table of ranges.&#160; While I haven’t experienced any sort of issues with the solution, a couple of things have recently occurred which has caused me to go back and take a look at the problem, and [...]]]></description>
			<content:encoded><![CDATA[<p>A while back, I posted a solution to a problem I was facing where I needed to generate a table of ranges.&nbsp; While I haven’t experienced any sort of issues with the solution, a couple of things have recently occurred which has caused me to go back and take a look at the problem, and see if I can come up with a more elegant solution.</p>
<p>The first was a comment by Jeff Moden on the original post; Jeff suggested that recursion may not be the best choice for a solution given the relatively large number of logical reads compared to his solution and/or a permanent Numbers table.&nbsp; Jeff posted a solution, but his solution only addressed the first part of the article (building a dynamic numbers table) and NOT the second part (coming up with a table of ranges).&nbsp; The problem that I was struggling with using a table of numbers was the dynamic span between rows; in other words, I couldn’t figure out how to force row 1 to start with 10, and row 2 start with 215</p>
<p>The second driving factor was the FizzBuzz solution I proffered yesterday; while I was reviewing that code, I had a glimmer of an idea about how to handle the dynamic spanning using MODULO.&nbsp; I reworked the solution using Jeff’s suggestion, as well as using a permanent numbers table.&nbsp; My examples are below:</p>
<h3>Original code:</h3>
<pre class="csharpcode">/*A dynamically generated <span class="kwrd">table</span> <span class="kwrd">of</span> ranges.
2009-01-25 Stuart R Ainsworth

http://www.codegumbo.com

Thanks <span class="kwrd">to</span> Stefan Keir Gordon <span class="kwrd">for</span> the inspiration
 http://www.keirgordon.com */

<span class="kwrd">DECLARE</span> @MaxRanges <span class="kwrd">int</span>, @MinChunk <span class="kwrd">int</span>, @<span class="kwrd">Start</span> <span class="kwrd">int</span>, @<span class="kwrd">End</span> <span class="kwrd">int</span>
<span class="kwrd">SELECT</span> @<span class="kwrd">Start</span>=10, @<span class="kwrd">End</span>=200000

/*@MaxRanges must be &lt;= 32767;
  <span class="kwrd">if</span> the range <span class="kwrd">between</span> <span class="kwrd">Start</span> <span class="kwrd">and</span> <span class="kwrd">End</span> <span class="kwrd">is</span> <span class="kwrd">large</span>,
  <span class="kwrd">and</span> @MaxRanges &gt; 32767, the <span class="kwrd">End</span> point won't be reached.*/

<span class="kwrd">SELECT</span> @MaxRanges=100, @MinChunk=2

<span class="kwrd">IF</span> (<span class="kwrd">SELECT</span> CEILING((@<span class="kwrd">End</span>-@<span class="kwrd">Start</span>)/(@MaxRanges*1.00)))&gt;@MinChunk
    <span class="kwrd">SET</span> @MinChunk = CEILING((@<span class="kwrd">End</span>-@<span class="kwrd">Start</span>)/(@MaxRanges*1.00))

;<span class="kwrd">WITH</span> Ranges(MinValue) <span class="kwrd">AS</span>
  (<span class="kwrd">SELECT</span> @<span class="kwrd">Start</span> <span class="kwrd">AS</span> MinValue
   <span class="kwrd">UNION</span> <span class="kwrd">ALL</span>
   <span class="kwrd">SELECT</span> (Minvalue + @MinChunk) <span class="kwrd">AS</span> MinValue
   <span class="kwrd">FROM</span> Ranges <span class="kwrd">WHERE</span> MinValue &lt; @<span class="kwrd">End</span>)
<span class="kwrd">SELECT</span> MinValue, MaxValue = <span class="kwrd">CASE</span> <span class="kwrd">WHEN</span> MinValue + @MinChunk &lt; @<span class="kwrd">End</span>
                 <span class="kwrd">THEN</span> MinValue + @MinChunk
                 <span class="kwrd">ELSE</span> @<span class="kwrd">End</span> <span class="kwrd">End</span>
<span class="kwrd">FROM</span> Ranges
<span class="kwrd">WHERE</span> MinValue &lt; @<span class="kwrd">End</span>
<span class="kwrd">OPTION</span>(MAXRECURSION 32767)</pre>
<h3>Modification based on Jeff’s suggestion:</h3>
<pre class="csharpcode">/*A dynamically generated <span class="kwrd">table</span> <span class="kwrd">of</span> ranges. part 2
2009-09-27 Stuart R Ainsworth

http://www.codegumbo.com

Thanks <span class="kwrd">to</span> Jeff Moden <span class="kwrd">for</span> the inspiration*/

<span class="kwrd">DECLARE</span> @MaxRanges <span class="kwrd">int</span>, @MinChunk <span class="kwrd">int</span>, @<span class="kwrd">Start</span> <span class="kwrd">int</span>, @<span class="kwrd">End</span> <span class="kwrd">int</span>
<span class="kwrd">SELECT</span> @<span class="kwrd">Start</span>=10, @<span class="kwrd">End</span>=200000
<span class="kwrd">SELECT</span> @MaxRanges=100, @MinChunk=2

<span class="kwrd">IF</span> (<span class="kwrd">SELECT</span> CEILING((@<span class="kwrd">End</span>-@<span class="kwrd">Start</span>)/(@MaxRanges*1.00)))&gt;@MinChunk
    <span class="kwrd">SET</span> @MinChunk = CEILING((@<span class="kwrd">End</span>-@<span class="kwrd">Start</span>)/(@MaxRanges*1.00))

<span class="kwrd">SELECT</span> MinValue, MaxValue = <span class="kwrd">CASE</span> <span class="kwrd">WHEN</span> MinValue + @MinChunk &lt; @<span class="kwrd">End</span>
                 <span class="kwrd">THEN</span> MinValue + @MinChunk
                 <span class="kwrd">ELSE</span> @<span class="kwrd">End</span> <span class="kwrd">End</span>
<span class="kwrd">FROM</span> (    <span class="kwrd">SELECT</span>
            ROW_NUMBER() <span class="kwrd">OVER</span> (<span class="kwrd">ORDER</span> <span class="kwrd">BY</span> (ac1.Object_ID)) -1 + @<span class="kwrd">Start</span> <span class="kwrd">AS</span> MinValue
        <span class="kwrd">FROM</span> Master.sys.columns ac1
        <span class="kwrd">CROSS</span> <span class="kwrd">JOIN</span> Master.sys.columns ac2) x
<span class="kwrd">WHERE</span> (MinValue = @<span class="kwrd">Start</span>
    <span class="kwrd">OR</span> (Minvalue-@<span class="kwrd">Start</span>) % @MinChunk = 0)
    <span class="kwrd">AND</span> MinValue + @MinChunk &lt;= @<span class="kwrd">End</span> + @MinChunk</pre>
<p><style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</p>
<p>I also used a permanent table of numbers (per Jeff’s suggestion), but given the similarity to Jeff’s modification, I won’t post the code here.&nbsp; Simply replace the subquery with a numbers table (you’ll need to monkey with the math to get the dynamic starting point).&nbsp; What was interesting to me was the output for each of the three solutions when using SET STATISTICS IO and TIME:</p>
<h3></h3>
<h3>Original code:</h3>
<pre class="csharpcode"><span class="kwrd">Table</span> <span class="str">'Worktable'</span>. Scan <span class="kwrd">count</span> 2, logical <span class="kwrd">reads</span> 607, physical <span class="kwrd">reads</span> 0, <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0, lob logical <span class="kwrd">reads</span> 0, lob physical <span class="kwrd">reads</span> 0, lob <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0.

<span class="kwrd">SQL</span> Server Execution Times:   CPU <span class="kwrd">time</span> = 16 ms,  elapsed <span class="kwrd">time</span> = 88 ms.</pre>
<h3>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
</h3>
<h3>Modification (dynamic table):</h3>
<pre class="csharpcode"><span class="kwrd">Table</span> <span class="str">'syscolpars'</span>. Scan <span class="kwrd">count</span> 2, logical <span class="kwrd">reads</span> 19, physical <span class="kwrd">reads</span> 0, <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0, lob logical <span class="kwrd">reads</span> 0, lob physical <span class="kwrd">reads</span> 0, lob <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0.

<span class="kwrd">SQL</span> Server Execution Times:   CPU <span class="kwrd">time</span> = 187 ms,  elapsed <span class="kwrd">time</span> = 203 ms.</pre>
<h3>Modification (permanent table):</h3>
<pre class="csharpcode"><span class="kwrd">Table</span> <span class="str">'NUMBERS'</span>. Scan <span class="kwrd">count</span> 1, logical <span class="kwrd">reads</span> 424, physical <span class="kwrd">reads</span> 0, <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0, lob logical <span class="kwrd">reads</span> 0, lob physical <span class="kwrd">reads</span> 0, lob <span class="kwrd">read</span>-ahead <span class="kwrd">reads</span> 0.

<span class="kwrd">SQL</span> Server Execution Times:   CPU <span class="kwrd">time</span> = 125 ms,  elapsed <span class="kwrd">time</span> = 156 ms.</pre>
<p>At first glance, it would appear that Jeff’s assertion is correct; the number of logical reads is greatly reduced by his suggested modification (more so by the dynamic table than the permanent table, interestingly enough).&nbsp; However, the CPU time is increased.&nbsp; And, while I know that execution plans are no guarantee for performance, in every situation SQL Server estimated that avoiding the original code was 0% of the three plans (dynamic modification 65% and permanent numbers table 35%).</p>
<p>So now, I’m stuck.&nbsp; I can see Jeff’s point, but I’m not sure that a solution based on his suggestion is that much better than my original solution; do I worry more about I/O or CPU? </p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2009/09/27/building-ranges-using-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FizzBuzz</title>
		<link>http://codegumbo.com/index.php/2009/09/27/fizzbuzz/</link>
		<comments>http://codegumbo.com/index.php/2009/09/27/fizzbuzz/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 04:14:55 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2009/09/27/fizzbuzz/</guid>
		<description><![CDATA[Stumbled across Mike Hillwig’s post in response to a question posed by Brent Ozar.&#160; Depending on how literally you want to use the word “print” (do you mean the actual command, or do you just want output?), I think I have a slightly more elegant solution than what Mike proposed. SELECT CASE WHEN n%3=0 AND [...]]]></description>
			<content:encoded><![CDATA[<p>Stumbled across <a href="http://thecrankydba.com/2009/09/25/fizzbuzz/" target="_blank">Mike Hillwig’s</a> post in response to a question posed by <a href="http://www.brentozar.com/archive/2009/01/top-10-interview-questions-to-ask-senior-dbas/" target="_blank">Brent Ozar</a>.&nbsp; Depending on how literally you want to use the word “print” (do you mean the actual command, or do you just want output?), I think I have a slightly more elegant solution than what Mike proposed.</p>
<pre class="csharpcode"><span class="kwrd">SELECT</span> <span class="kwrd">CASE</span> <span class="kwrd">WHEN</span> n%3=0 <span class="kwrd">AND</span> n%5=0 <span class="kwrd">THEN</span> <span class="str">'FizzBuzz'</span>
            <span class="kwrd">WHEN</span> n % 3 = 0 <span class="kwrd">THEN</span> <span class="str">'Fizz'</span>
            <span class="kwrd">WHEN</span> n % 5 = 0 <span class="kwrd">THEN</span> <span class="str">'Buzz'</span>
            <span class="kwrd">ELSE</span> <span class="kwrd">CONVERT</span>(<span class="kwrd">varchar</span>(8), n) <span class="kwrd">END</span> <span class="kwrd">as</span> "N"
<span class="kwrd">FROM</span> (    <span class="kwrd">SELECT</span> <span class="kwrd">TOP</span> 100 ROW_NUMBER() <span class="kwrd">OVER</span> (<span class="kwrd">ORDER</span> <span class="kwrd">BY</span> (ac1.Object_ID)) <span class="kwrd">AS</span> "N"
    <span class="kwrd">FROM</span> Master.sys.All_Columns ac1) x</pre>
<style type="text/css">.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
</style>
<p>Basically, it avoids the WHILE loop; however, if you must use a PRINT command, then Mike’s suggestion is probably as elegant as I can imagine.&nbsp; What’s interesting is that this may also provide me a better solution to my <a href="http://codegumbo.com/index.php/2009/01/25/building-ranges-using-a-dynamically-generated-numbers-table/#comments" target="_blank">need to build a dynamic range</a> that I posted a while back.&nbsp; I’ll have to think about it a bit more, but I think it’s possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2009/09/27/fizzbuzz/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Coming to PASS Summit 2009: Twitter BINGO!</title>
		<link>http://codegumbo.com/index.php/2009/09/25/coming-to-pass-summit-2009-twitter-bingo/</link>
		<comments>http://codegumbo.com/index.php/2009/09/25/coming-to-pass-summit-2009-twitter-bingo/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 17:27:11 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>
		<category><![CDATA[The Social Web]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2009/09/25/coming-to-pass-summit-2009-twitter-bingo/</guid>
		<description><![CDATA[So, last year at PASS Summit, I had my first real experience with a heavily-twittered event.&#160; What was interesting was that I met a lot of people in real-life that I had just recently begun following on Twitter; I had made the comment (in passing) to someone that we should have had BINGO cards to [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin: 10px; display: inline" align="left" src="http://upload.wikimedia.org/wikipedia/commons/f/fb/Bingo_card_-_02.jpg" width="300" height="393"> So, last year at PASS Summit, I had my first real experience with a heavily-<a href="http://www.twitter.com" target="_blank">twittered</a> event.&nbsp; What was interesting was that I met a lot of people in real-life that I had just recently begun following on Twitter; I had made the comment (in passing) to someone that we should have had BINGO cards to keep track of all of the face-to-face interaction.&nbsp; This year (since I just recently found out that I was going to Summit 2009 – yay!), I decided to do what I could to make the idea come to fruition.&nbsp; Since I know <a href="http://www.brentozar.com/" target="_blank">Brent Ozar</a> is big into social networking and he has some pull with <a href="http://www.brentozar.com/what-i-do/" target="_blank">Quest</a>, I approached him with the idea.</p>
<p>We’re still working out the details, but it looks like Twitter BINGO is on for <a href="http://summit2009.sqlpass.org/" target="_blank">Summit 2009</a> (note: this is NOT <a href="http://bingostreet.com/news-20090729/twitter-launches-version-of-online-bingo-online-bingo-news" target="_blank">TwitterINGO</a>).&nbsp; I do know that we’re going to need at least 25 tweeps (is there another name for people who use Twitter?) to volunteer as game board icons.&nbsp; As an icon, you’ll be sought out by game players seeking to fill in their game cards.&nbsp; If you’re interested in volunteering, please leave a comment with your twitter handle below (or DM me, <a href="http://twitter.com/stuarta" target="_blank">@stuarta</a>); to be eligible you must:</p>
<ul>
<ul>
<ul>
<ul>
<li>Use Twitter semi-regularly;
<li>Be planning to attend PASS Summit 2009, and;
<li>Be willing to talk to lots of people you don’t know now face-to-face.</li>
</ul>
</ul>
</ul>
</ul>
<p>More details will follow as we start working the kinks out, but I’m hoping this will help the online twitter community intersect with meatspace.&nbsp; Looking forward to hearing from volunteers! </p>
<p><strong>EDIT:</strong> Since it sounds like Quest and/or SQLServerPedia might be putting up prizes for this, we’re going to have to exclude vendor twitter accounts from playing.&nbsp; Personal accounts are fine, so if you work for Quest, and they have a booth at PASS, you can still play as yourself.&nbsp; Kapiche?</p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2009/09/25/coming-to-pass-summit-2009-twitter-bingo/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Another tale of the unwilling DBA &#8211; tempdb and the LUN</title>
		<link>http://codegumbo.com/index.php/2009/09/11/another-tale-of-the-unwilling-dba-tempdb-and-the-lun/</link>
		<comments>http://codegumbo.com/index.php/2009/09/11/another-tale-of-the-unwilling-dba-tempdb-and-the-lun/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 11:10:16 +0000</pubDate>
		<dc:creator>stuart</dc:creator>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQLServerPedia Syndication]]></category>

		<guid isPermaLink="false">http://codegumbo.com/index.php/2009/09/11/another-tale-of-the-unwilling-dba-tempdb-and-the-lun/</guid>
		<description><![CDATA[As many of you know, I’m a database DEVELOPER; I’ve been a DBA in the past, but my real specialty lies in getting different database platforms to exchange information with SQL Server.&#160; I haven’t done a lot of hands-on administration (backups, maintenance plans, etc) in a while, but that’s changed recently.&#160; Our primary production DBA [...]]]></description>
			<content:encoded><![CDATA[<p>As many of you know, I’m a database DEVELOPER; I’ve been a DBA in the past, but my real specialty lies in getting different database platforms to exchange information with SQL Server.&nbsp; I haven’t done a lot of hands-on administration (backups, maintenance plans, etc) in a while, but that’s changed recently.&nbsp; Our primary production DBA has been out of the office for an extended period of time, and I’ve had to step back into a support role.</p>
<p>One of the projects he was working on before he left was performance tuning our databases on the SAN; he had recently segregated the tempdb into its own LUN, and everything looked OK, but during some of our overnight jobs we started seeing messages like:</p>
<blockquote><p><font size="2" face="Courier New">Exception Information: System.Data.SqlClient.SqlException: The transaction log for database &#8216;tempdb&#8217; is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases</font></p>
</blockquote>
<p>Uh-oh.&nbsp; I had no clue where to begin; I knew that the database was on its own LUN, and I knew that that LUN was full, but how big should the tempdb LUN be?&nbsp; I tried searching the Internet for guidance, but got nowhere; there doesn’t seem to be a rule-of-thumb for sizing tempdb based on other databases.</p>
<p>The LUN was currently sized for 10GB; we have 1.5TB of data.&nbsp; I knew that seemed small, but we had been running for a couple of weeks without issues, so I suggested to our production DBA team that we should double it, and see what happens.&nbsp;&nbsp; All was well until we got to the month-end processes, and BAM! 20GB of space sucked up by tempdb.&nbsp; Now what?</p>
<p>I turned to Twitter, and got several helpful (and some not so helpful) responses; as many people pointed out, it needs to have as much free space available as possible, and the size of it was more dependent on activity than the amount of data.&nbsp; Both excellent points, but neither one addresses the need to have a specific LUN size on a SAN.&nbsp; Space ain’t free.</p>
<p><a href="http://twitter.com/venzann" target="_blank">@venzann</a> came up with the best guide: “Size of indexes + estimate on largest transaction size + wiggleroom.”</p>
<p>Using his suggestion on our 1.5TB server, I came up with an estimate of 430GB in indexes.&nbsp;&nbsp; I stopped there, knowing that my SAN admin would shoot me if I tried to run that past them; besides, our server had run OK for a couple of weeks on 10GB; if we needed 430GB, we would have choked long before that (in retrospect, our production DBA should have recorded the size of tempdb BEFORE he moved it to a LUN; c’est la vie).&nbsp;&nbsp; I decided to pick a smaller number: 100 GB.&nbsp; Why?</p>
<p>First, it made logical sense using @venzann’s formula.&nbsp; We use a partitioning schema for most of our data, so the sum of the active indexes was really only about 75GB.&nbsp; Other indexes may be occasionally used by queries, but 90% of our searches only look at the last 2 days worth of data.</p>
<p>Second, it’s a nice round number.&nbsp; 100GB is 15% of 1.5TB.&nbsp; Round numbers are good for rules-of-thumb.&nbsp; You never hear anyone say “that ____ should be 14% of ____; just a rule-of-thumb”.</p>
<p>Finally, it was the maximum size I could request from our SAN admin without them ordering new drives.&nbsp; Hey, if someone says you can have $100, you don’t say “all I need is 50” (unless of course, you’re <a href="http://www.imdb.com/character/ch0008755/" target="_blank">Porter</a>).</p>
<p>Anyway, it seems to be working; we’re humming along now without errors; in another 20 days or so, we’ll be doing month-end again, and we’ll see what happens.&nbsp; I can’t wait for the production DBA to get back, so I can quit thinking about this stuff, and go back to my safe zone. </p>
]]></content:encoded>
			<wfw:commentRss>http://codegumbo.com/index.php/2009/09/11/another-tale-of-the-unwilling-dba-tempdb-and-the-lun/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

