<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www2.sqlblog.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx</link><description>"Lonely but free I'll be found Drifting along with the tumbling tumbleweeds" - Supremes, "Tumbling Tumble Weeds" Welcome to the first installment of what I hope will be a regular feature on this blog, Anti-Patterns and Malpractices. As a consultant, I</description><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.1)</generator><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#3987</link><pubDate>Sat, 15 Dec 2007 16:37:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3987</guid><dc:creator>Paul Nielsen</dc:creator><description>&lt;p&gt;I've noticed this pattern - I call it the data bucket pattern but it's the same idea - is popular among prior Access programmers who used lots of make-table queries to move the data to the desired answer. And I've seen some production databases that are set up this way - different table for the same data but different workflow states of the data, so the data moves from table to table in the lifecycle of the data.&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#3989</link><pubDate>Sat, 15 Dec 2007 16:49:38 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3989</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Paul,&lt;/p&gt;
&lt;p&gt;You and Scott think alike -- he also mentioned Access as the source of some of this, and I forgot to write that in the post. &amp;nbsp;Thanks for bringing that up!&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#3995</link><pubDate>Sat, 15 Dec 2007 19:00:56 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3995</guid><dc:creator>Denis Gobo</dc:creator><description>&lt;p&gt;No matter how far down the wrong road you've gone, turn back.&lt;/p&gt;
&lt;p&gt;Turkish Proverb&lt;/p&gt;
&lt;p&gt;I think people get emotionally attached to their code, they think it is their baby and feel hesitant to throw it out (understandibly so). They try to patch it here, patch it there until their code looks like a quilt. We have all done this, I have done it too. I spend 2 days on that code, I am not throwing it out, I know I can fix it.....&lt;/p&gt;
&lt;p&gt;This is simillar to the fact that you have slowly changing dimensions in data warehousing, this thing changes too.....only for the worst. Every change you add makes it worse. You have to be bitten a couple of times until you realize that rewriting is the only option. Unfortunately it takes time (and money) until you realize that. Enough rambling, time for a Crown Royal with ice....:-)&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#3996</link><pubDate>Sat, 15 Dec 2007 19:13:32 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3996</guid><dc:creator>dmarkle</dc:creator><description>&lt;p&gt;Adam:&lt;/p&gt;
&lt;p&gt;Good example. &amp;nbsp;I'll say, though, that this can be a good way for beginners to START to code. &amp;nbsp;They might not have the skills to have thought out the whole thing beforehand in a set-based way. &amp;nbsp;This is surely the way I started to write SQL waay back when I was first learning it. &amp;nbsp;But the missing step for a beginner is this: REFACTOR! &amp;nbsp;&lt;/p&gt;
&lt;p&gt;Beginners: If you're learning, start out by gathering your datasets independently, then figure out how to join them together into a concise, high-performance query. &amp;nbsp;Once you do do that a few times, you'll gain the skills to do as Adam says and think out more involved queries in just a few minutes. &amp;nbsp;Don't just stop with the &amp;quot;Tumbling Data&amp;quot; pattern and call it &amp;quot;good enough&amp;quot;.&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#3998</link><pubDate>Sat, 15 Dec 2007 20:17:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:3998</guid><dc:creator>finckle</dc:creator><description>&lt;p&gt;I agree with everything in the post but I sometimes prefer it when something (reports?) is written in the Tumbling Data Anti-Pattern way! I often have to look at stored procs used by reporting services reports, the reports are complex beasts and the stored procs producing them typically consists of a single very complex SELECT statement.&lt;/p&gt;
&lt;p&gt;These SELECT statements take time to understand and making a change to such an animal really can be a daunting task. I get a sinking feeling when I open one of these and have to make a change, on the other hand, when the stored proc was done using the Tumbling Data Anti-Pattern I can more easily understand how the original developer was thinking and subsequently my change becomes easier. Looking at little snippets and understanding them as you go are just easier IMHO.&lt;/p&gt;
&lt;p&gt;I guess these complex SELECT statements can be documented and that would ease my frustrations. In an environment where complex reports are requested everyday and sometimes never looked at again that just isn’t going to happen.&lt;/p&gt;
&lt;p&gt;Perhaps the Anti-Patterns is more self documenting than the alternative?&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4002</link><pubDate>Sun, 16 Dec 2007 01:58:36 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4002</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Finkle:&lt;/p&gt;
&lt;p&gt;I agree that this kind of code CAN be easier to understand, but not necessarily so. &amp;nbsp;I wish I could post a sample of some of the real code I've recently been working with so that you can see just how bad it can get. &amp;nbsp;My re-written, single SELECT query is heavily commented and I guarantee that the next developer who sees it will only have to pull out 1/16 of the hair that I had to pull out while reading the gigantic temp table-based solution :-)&lt;/p&gt;
&lt;p&gt;Plus, there's the performance issue. &amp;nbsp;When it takes an hour to run each step because there are no proper predicates used, it can be very difficult to debug and/or figure out what's going on... &lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4024</link><pubDate>Mon, 17 Dec 2007 03:28:31 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4024</guid><dc:creator>Scott Diehl</dc:creator><description>&lt;p&gt;Credit for naming an anti-pattern - a dubious honor, but I'll take what I can get.&lt;/p&gt;
&lt;p&gt;We can all agree that the tumbling data anti-pattern is inefficient; as Adam mentions, the unnecessary hammering of hardware resources can make you very unpopular with both end users and other developers sharing your environment.&lt;/p&gt;
&lt;p&gt;The more subtle danger, however, is the habits of mind produced by repeatedly implementing such an approach to complex query logic. &amp;nbsp;What happens when you have to extend such a query? &amp;nbsp;Seems to make good sense, at the time, to fill up another temp table (or..egads...truncate and fill up some of those &amp;quot;reporting&amp;quot; tables you've left lying about), tacking the output onto the end of the existing statements. &amp;nbsp;It's like query crack - just one more temp table, please - when a more effective, multi-module design might actually be both less complex AND more self-documenting.&lt;/p&gt;
&lt;p&gt;I've seen a number reports based on this anti-pattern lately. &amp;nbsp;When you see a query moving on to it's fifth temp table, after pumping output from one #NotAnotherOne to another like some out-of-control chain of Unix shell scripts, well, be very afraid. &amp;nbsp;And talk to the developer about implementing a nice derived table, maybe.&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4038</link><pubDate>Mon, 17 Dec 2007 17:24:46 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4038</guid><dc:creator>Merrill Aldrich</dc:creator><description>&lt;p&gt;Well put - plus &amp;quot;tumbling&amp;quot; makes me thing of the sound forgotten change makes in the dryer; a server probably sounds similar when running a bunch of these temp-table-based solutions at the same time!&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4057</link><pubDate>Tue, 18 Dec 2007 13:43:15 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4057</guid><dc:creator>Madhivanan</dc:creator><description>&lt;p&gt;Newbies always start with this approach.&lt;/p&gt;
&lt;p&gt;I remember now how a newbie wrote VB code to find out date_joined value for a particular employee&lt;/p&gt;
&lt;p&gt;The code was something like&lt;/p&gt;
&lt;p&gt;set empname=txt_emp.text&lt;/p&gt;
&lt;p&gt;Set Rs=con.execute(&amp;quot;Select * from employees&amp;quot;)&lt;/p&gt;
&lt;p&gt;While Rs.count&amp;gt;0&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; if Rs(&amp;quot;emp_name&amp;quot;)=empname then&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; messagebox rs(&amp;quot;date_joined&amp;quot;)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; end if&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; Rs.movenext&lt;/p&gt;
&lt;p&gt;Loop&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4064</link><pubDate>Tue, 18 Dec 2007 15:44:44 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4064</guid><dc:creator>Joe Celko</dc:creator><description>&lt;p&gt;This pattern is the old &amp;quot;scratch tape&amp;quot; model of electronic data processing (EDP). &amp;nbsp;Tape drives were expensive, so small shops would have only two or three of them. &amp;nbsp;You would hang a source tape on drive #1, and extract a subset to drive#2. &amp;nbsp;Rewind #1 and either hang a new scratch tape or write a file separator on #2 and extract the next subset. &amp;nbsp;&lt;/p&gt;
&lt;p&gt;We had no physical choice about this with magnetic tapes. &amp;nbsp;What I cannot figure out is why people who are not that old got the idea. &amp;nbsp;&lt;/p&gt;
</description></item><item><title>A year in review, The 21 + 1 best blog posts on SQLBlog </title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#4227</link><pubDate>Thu, 27 Dec 2007 21:11:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:4227</guid><dc:creator>Denis Gobo</dc:creator><description>&lt;p&gt;A year in review, The 21 + 1 best blog posts on SQLBlog Best posts according to me, it might have been&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5068</link><pubDate>Thu, 14 Feb 2008 02:23:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5068</guid><dc:creator>Jeff</dc:creator><description>&lt;p&gt;Great post, Adam. &amp;nbsp;And even though many great SQL programmers indeed embrace the &amp;quot;set-based&amp;quot; concept of doing things all in one big step, that doesn't mean that we still don't need to stop before coding and really think about what we are trying to do, and the best way to get it done. &amp;nbsp;I discuss that a bit here (it's an older post, but I am not sure if you've seen it):&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://weblogs.sqlteam.com/jeffs/archive/2007/04/30/60192.aspx"&gt;http://weblogs.sqlteam.com/jeffs/archive/2007/04/30/60192.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The lesson, as always: if you spend more time coding than thinking, in ANY language, you are doing something wrong.&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5277</link><pubDate>Tue, 26 Feb 2008 15:10:55 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5277</guid><dc:creator>Ward Pond</dc:creator><description>&lt;p&gt;Great post, Adam.&lt;/p&gt;
&lt;p&gt;My only quibble is that the Supremes would've been ridden out of Motown on a rail if they recorded &amp;quot;Tumbling Tumbleweeds,&amp;quot; which was most famously recorded by the Sons of the Pioneers.&lt;/p&gt;
&lt;p&gt;It's also an important component of the soundtrack of The Big Lebowski.&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://en.wikipedia.org/wiki/Tumbling_Tumbleweeds"&gt;http://en.wikipedia.org/wiki/Tumbling_Tumbleweeds&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;:)&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; -wp&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5278</link><pubDate>Tue, 26 Feb 2008 15:12:57 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5278</guid><dc:creator>Ward Pond</dc:creator><description>&lt;p&gt;Okay.. &amp;nbsp;I'm wrong.. &amp;nbsp;Wikipedia says the Supremes covered it in '95.&lt;/p&gt;
&lt;p&gt;Wonders never cease..&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5308</link><pubDate>Wed, 27 Feb 2008 16:43:50 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5308</guid><dc:creator>Adam Machanic</dc:creator><description>&lt;p&gt;Well it's my fault for not properly researching the origins of the song. &amp;nbsp;Clearly it is not the Supremes who should get the credit for the lyrics ... thanks for pointing that out!&lt;/p&gt;
</description></item><item><title>Building complex data sets</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5979</link><pubDate>Tue, 01 Apr 2008 22:49:57 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5979</guid><dc:creator>SimonS Blog on SQL Server Stuff</dc:creator><description>&lt;p&gt;If you&amp;amp;#39;ve got a complex data set to produce how should you do it. Adam Machanic has posted about&lt;/p&gt;
</description></item><item><title>re: Anti-Patterns and Malpractices, Volume 1: Tumbling Data</title><link>http://www2.sqlblog.com/blogs/adam_machanic/archive/2007/12/15/anti-patterns-and-malpractices-volume-1-tumbling-data.aspx#5997</link><pubDate>Wed, 02 Apr 2008 17:14:05 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:5997</guid><dc:creator>SDC</dc:creator><description>&lt;p&gt;Access is evil. &amp;nbsp;It's the Access of Evil (TM)&lt;/p&gt;
</description></item></channel></rss>