Tony Davis

Simple-Talk Editor
News, views and good brews

SQL Server Sheep Ticks

Published Wednesday, October 28, 2009 12:09 PM

The doggedness with which certain SQL Server "myths" cling to the coat of the SQL Server community is really quite astonishing. They are the proverbial "sheep ticks"; very annoying and incredibly difficult to dislodge. And even when you think you've managed it, their embedded jaws remain to provoke further irritation.

A classic case in point is the "SELECT…INTO" myth, which states that its use should be avoided as it will cause serious blocking issues in SQL Server. Way back in the days of version 6.5, i.e. circa 1996, SQL Server had a serious problem with SELECT…INTO. Due to limitations in the way page allocation worked, these statements caused massive contention in tembdb. In effect, tempdb was "locked" for the duration of the statement, and so any other process that required access to tempdb was blocked. Many a time, a long-running query would pour its results into a new table via a SELECT…INTO, and effectively lock an entire production application for maybe an hour until KILLed by the DBA. It was an unforgettable experience whenever it happened, remembered vividly both by the users and the harassed DBAs.

The problem was essentially fixed in version 7.0, more than 10 years ago, and yet the memory of the problem lives on so vividly in the minds of many DBAs that, to this day, the myth persists, and SELECT…INTO is effectively banned from the SQL Servers they manage. Of course, other DBAs have accepted that SELECT…INTO has been rendered harmless, and have cautiously released it into the wild. And yet, it seems that the jaws of this particular tick remain resolutely embedded in our skin.

In SQL Server 2000, the allocation system for tempdb was improved to greatly reduce contention issues, but the fact remained that SELECT…INTO, and other processes that made heavy use of tempdb, could still cause significant contention. In response, with SQL 2000 SP3, Microsoft introduced a new trace flag, -T1118. When activated, it forced "uniform extent allocations instead of mixed page allocations" and helped with tempdb scalability. Although still available in SQL Server 2005 and 2008, further architectural improvement has rendered this flag redundant…or has it? Speculation persists to the effect that if you are performing SELECT…INTOs then you should set the -T1118 flag in order to deal with the resulting tempdb contention. And yet others in the community have reported not being able to reproduce a single case where the flag has helped improve throughput in SQL Server 2005 or 2008.

It's not the fact such myths arise that surprises me, but the way they manage to persist for so long, and morph into new forms. Why is this? Is it a lack of clear information? Or difficulty in finding the information that is out there? What other "ticks" do we need to kill off once and for all, and how can we do it? Could a resource such as asksqlservercentral help de-flea the community?

Cheers,

Tony.

Comments

 

timothyawiseman@gmail.com said:

The issue is that one disaster or near disaster is far more memorable than being told a million times that has been fixed.  

And when you couple this with the fact that there are still SQL Server 6.5 servers floating out there in production use right now and so there are some working DBA's unfortunate enough to still have to face this myth head on and it will take a while longer before this particular myth dies out.

And then when you add in that DBAs tend to be on the conservative end of the technologists spectrum (remember that far more than application programmers or even system administrors, a DBA's core job often revolves around integrity, stability, and logging.) and myth's will indeed be hard to kill once they are firmly rooted.  
October 29, 2009 6:27 PM
 

ionFreeman said:

There's also the issue that being told that it's fixed is a long way from believing that it's fixed. It's hard to validate that some problems are actually gone, and any patch or service pack could bring them up in regression.

At least one enterprise software company with which I'm familiar had a habit of failing to reproduce customer issues, guessing at the customer problem, fixing the guess, and releasing the fix with some fanfare. So, it's nice to hear when problems are fixed, but it's not going to change your behavior.
November 2, 2009 1:17 AM
 

neilx said:

Other myths:

"I never use UNIONs as they are unacceptably slow"
"A normalized database is unusable in production"
"Always use IDENTITY primary keys as they are faster"

Note that many myths, including all of the above, are to do with performance, yet few people can give evidence.
November 2, 2009 4:29 AM
 

Charles Kincaid said:

The one thing that supports the IDENTITY myth is that most people use a 4 byte INTEGER for this.  The choice of a so called PRIMARY  key is that it is often expressed in a clustered index.  Therefore the the key on the clustered index is used as the pointer in all other indexes on same table.  This can bloat your indexes if you are using LastName, FirstName, MiddleName, Suffix as your key.

It is said that all UNIONs are bad.  Buit that is politics and not SQL.  :)
November 2, 2009 10:55 AM
 

r_honey said:

Well, it could also be due to human's inherent resistance to change, and that conventional wisdom (specially that imparted to you as a part of your learning process) tends to stick on with you longer with humans giving it greater weight over the new information available around.
November 3, 2009 10:00 AM
 

neilx said:

RE: Charles Kincaid comment

Hi Charles - The only thing that should support - or bust - a myth is empirical evidence.

This, of course, will end up being entirely product dependent - Oracle, MySQL, MS Sql Server, etc. may all give radically different results depending on how many rows and joins are involved in the benchmarks for IDENTITY vs non-identity primary keys. I for one wouldn't second guess it without running tests. Even then, I would need the IDENTITY column to be significantly faster to use it in preference to a real key if one exists. We need Jamie and Adam - http://dsc.discovery.com/fansites/mythbusters/mythbusters.html - on this one:-)

I didn't understand your point on UNIONS, sorry. Did you mean Unions as in I'm Alright Jack?
November 3, 2009 11:16 AM
 

williamd said:

The thing that is often forgotten when these myths are passed around, is one of the most used caveats in the world: IT DEPENDS.

This is something that seems to fit better in the database world than anywhere else in IT. No single one of the myths or so called best practices fits every single system in the world.

Sometimes the worst thing to have is a big name consultant passing out their opinion to a group of people.  As these big names pass out their knowledge "YMMV" is often implied but forgotten by the recipient.  

With the event of Web 2.0 the propogation of myths is incredible. You would think that the opposing force to these myths would have the same success, but again the point of varying mileage gets lost and chinese whispers wins again.

I agree with neilx that a sqlmythbuster team should be formed and methodically take each myth apart.  Maybe someone with the contacts (@Simple-talk) could get the big names to endorce such a series of webcasts and then spread the word.

P.S.  My favourite myth is that table variables are memory resident and never physically created in temp db and therefore better than temp tables.
November 10, 2009 2:57 AM
 

Tony Davis said:


      Many developers seem to regard SQL Server as if it were a science-fiction alien planet...
November 13, 2009 4:20 AM
 

Tony Davis said:


      Many developers seem to regard SQL Server as if it were a science-fiction alien planet...
November 13, 2009 4:25 AM
You need to sign in to comment on this blog


















<October 2009>
SuMoTuWeThFrSa
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567
Finding Stuff in SQL Server Database DDL
 You'd have thought that nothing would be easier than using SQL Server Management Studio (SSMS) for... Read more...

Mission Critical: SQL Server 2008 Performance Tuning Task List
 In which Buck Woody imagines how the US military would have tackled DBA checklists for... Read more...

Simple Query tuning with STATISTICS IO and Execution plans
 A great deal can be gleaned from the use of the STATISTICS IO and the execution plan, when you are... Read more...

Switching rows and columns in SQL
 When they use SQL Server, one the commoner questions that Ms Access programmers ask is 'Where's the... Read more...

Writing Efficient SQL: Set-Based Speed Phreakery
 Phil Factor's SQL Speed Phreak challenge is an event where coders battle to produce the fastest code to... Read more...