Common Sense

The longer I stay in IT, the more I realize I just don’t know what’s common sense and what isn’t.  I used to think all kinds of things were common sense but I’m having to change my opinion on them.  Keeping in mind that common sense changes with each industry, but there are some large overlaps.

For instance, I used to think it was common sense to actually test code before you put it into prod.  I no longer think that.  Apparently it’s something that has to be taught, drilled, practiced, and re-taught.  I’m just awed at how hard it is to get devs to test code, and quite often, how much harder it is to get companies to see the value of testing.

As well, I used to think that it was common sense to test the same scenario that you want to go into prod.  This sounds like the same one above but it’s not.  Here, the testing is happening, but they’re testing something different than is going to be in prod.  I saw this last year actually.  A company was testing a repl scenario to send their prod data to their reporting server.  They tested 25 tables and latency was excellent so they pushed forward with putting it into prod.  And of course the scenario crashed and burned in prod because they published over 200 tables in that DB, and the same number in like 10 other DBs.  So evidently it’s not common sense to test exactly what you’re going to put into prod.  And there are so many more examples of this one I could fill a book.

I used to also think that it was common sense to troubleshoot the same scenario you’re having trouble with, but again, I’m wrong.  I recently saw a scenario where a tech was troubleshooting a data load.  The load process was put on a different server than the one it usually runs on and it took about 4x longer than normal.  And of course that’s cause for alarm especially since both source and destination servers are in the same data center.  At least it would be alarming if he were comparing the same processes.  In prod he was running an incremental process and on his test box he was running a full load process.  So let me see if I’ve got this straight, you went from an incremental process to a full load and you’re surprised it’s taking longer.  I’m actually speechless.  Hopefully you at least now know why we have the incremental to begin with.

Again, I could go on forever, but I think you get the point.  Common sense isn’t so common anymore.  I’m not sure we can say that about anything anymore, much less IT stuff.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

More Questionable Code

A couple pieces of code came across my desk yesterday and they’re definitely the kind of thing you read about… if nowhere else, then here for sure.  This was code that a dev sent me that is to be deployed next week.

The first one could actually cause a problem so I’ll talk about it first.

I’ll write the pseudo-code because I don’t have the actual code in front of me right now.  It goes like this:

1.  Check if the Whale schema exists.

2.  If it does exist then drop it.

3.  Create the Whale schema.

Ok, so that’s exactly what the script does. Here, I’ll go ahead and attempt the code.  I didn’t look it up so it may have a slight error in it, but you get the idea.

If exists (select name from sys.schemas where name = ‘Whale’)

BEGIN

drop schema Whale

END;

Create schema Whale with authorization = ‘dbo’;

So what’s wrong with this code you ask?  It’s simple, here’s the logic.

First, if it exists and you drop it then why just turn around and recreate it in the next step?  What’s the point of that?  So if your goal is to create the schema then everything above the ‘create’ line is useless.  And I know what you’re thinking… so what?  What’s the big deal if a tiny query gets run during a deployment?  It’s not like it’s going to drag the system down.  Well, you’re right about that, but it could kill the deployment.  If that schema did exist and it actually contained objects, then the drop statement would fail until you put those objects somewhere else.  So with there being no code to check that objects exist inside, you could be dooming the deployment to an unnecessary error.  You could also say that you know that the schema doesn’t exist so there’s nothing to worry about.  That’s fine, then take out the check and the drop.  If you know it’s not there, then take it out.  It’s called having concise code and it’s something that we lack in this industry these days.  Let me illustrate this with something completely ridiculous that also doesn’t really effect performance.

Create table #t1 (col1 int)

truncate table #t1

truncate table #t1

truncate table #t1

truncate table #t1

truncate table #t1

Insert #t1 Select 1

Ok, so look at that code above.  I created a temp table and then truncated it 5x.  That’s not going to effect performance at all because there’s no data in it since it was just created and there are no pages.  Then I go ahead and insert a row.  I can’t think of anyone who would let this kind of thing go on in an SP, or in deployment code, but we’re expected to let useless checks stay in our scripts. 

This code was clearly scripted in the wizard so it’s not like the dev went out of his way to do this by hand, but it’s the mark of a fairly inexperience coder to let the wizard create scripts and not inspect what it’s giving you.

The other piece of code doesn’t really do any damage as much as it’s just annoying.  In fact, it’s really 2 different scripts.  They’re create view scripts and the first one reads something like this:

create view MyView

as

Select MyFavoriteTable.col1,

MyFavoriteTable.col2,

MyFavoriteTable.col3,

MyFavoriteTable.col4,

MyFavoriteTable.col5,

MyFavoriteTable.col6,

MyFavoriteTable.col7,

MyFavoriteTable.col8,

MyFavoriteTable.col9,

MyFavoriteTable.col10

from MyFavoriteTable as MyFavoriteTable

Ok, so even typing this in the blog pisses me off.  And again, it’s just a style thing, but this just drives me crazy.  What drives me crazy the most is that this dev doesn’t understand what aliases are for.  To alias a table with the same name as the table itself defeats the purpose of having the alias in the first place.  Here a much better alias would have been mft or mt or m.  Hell, you could even go as far as MyFT or something like that.  Here, I’ll play one of those out for you and you tell me which one you’d rather read.

Select mft.col1,

mft.col2,

mft.col3,

mft.col4,

mft.col5,

mft.col6,

mft.col7,

mft.col8,

mft.col9,

mft.col10

from MyFavoriteTable as mft

Forget reading, which one of those would you rather type?  It’s just more concise and easier to read.  I happen to know the dev who wrote this and his opinion is that the full table name makes it easier to read when you’ve got larger joins.  Personally, I’ve never known anyone to complain about short aliases before, and again, I honestly think this boils down to inexperience.  When I first started coding well over a decade ago, I used to need things to be presented to me in very specific ways too.  It was the only way I could read the code.  That kind of thing is much less important to me now that I have been doing it for a long time.  Why?  Because I know how to code.

So the second thing about this script that bugs me is the fact that he saw the need to alias a query with a single table in it.  Now you’re just being obstinate for no reason.  I know the argument though.  He probably would say that he did it for consistency.  The only problem with that is the other create view script he submitted didn’t have the same stupid aliasing structure, so where’s the argument now?

Ok, so this code was clearly brought to us as part of a code review so the next logical question is why don’t we just reject the code if it bothers us so badly?  Well, the answer is simple.  Like so many places, our code reviews are merely perfunctory process placeholders.  Our lead dev has made it very clear that he’s going to do whatever he likes no matter what we say.  We’ve rejected code plenty of times for really valid process or performance reasons and he always thumbs his nose up at us and pushes it into prod anyway.  I really don’t understand how he’s gotten such a superior attitude towards the DBAs, but it’s completely unwarranted.  He acts like we’re in this just to piss on his parade and make him look bad, but we’re really only trying to help.  But we don’t even bother anymore.  What’s the point?  He knows more than the rest of us put together so we don’t even bring stuff up anymore.

So that’s my rant for tonight.  Remember, use aliases wisely and be as consistent as you can.  And for everyone’s sake listen to what your DBAs are telling you for a change.  They’re really only trying to help.

Sick of LiteSpeed

I’m just getting sick of dealing with LIteSpeed problems.  My big DW was using a lower version of LS and it was fine for a long time.  Then I upgraded to the new version and my backups went from 30mins to like 10hrs.  So I went back to the previous version.  Then I upgraded my DB from yukon to katmai and i upgraded LS at the same time hoping that the even newer version would work better with katmai on my big DW system.  That hasn’t happened.  It’s been ridiculous trying to get backups to even complete.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

Under the Radar

So I’m sitting here at the blogger table at the 2nd PASS keynote by Tom Casey and he brings up a good point.  Now this is something I’ve blogged about in the past, but it’s about that guy in your org who goes off and does his own thing and puts a small DB on his desktop and starts doing data loads, and crunching things on his own.  That can be a problem because IT isn’t involved and IT doesn’t even know it exists.  That’s why slammer was so devastating because of all those “unauthorized” DBs out there.  And everyone should be going through IT for these types of projects… or should they?

Tom actually brings up a good point that every piece of data, or every query doesn’t have to go through IT.  Some things aren’t big enough or are only for short-lived times and there’s no reason for it to be spun up as a project.  And again this is a fine line because as a DBA I really do have to know where my data’s going and if I let everyone just pull whatever they wanted, then server performance would be crap.  So it’s a tough line to walk because while we need to have some kind of decent control over where our server resources are going, we also don’t need to be involved in every little thing that crosses someone’s mind.

IT quite often also isn’t very responsive because we do have to plan things better than the users do and I think they lose sight of that.  The trick is for us to make it a real project while at the same time not slowing them down too much.

So I’m gonna go ahead and say that office users are free to keep things under our radar, but know that comes at a price.  If you lose the data or the code or it starts performing badly, then don’t come crying to us.  These are the things that IT brings to the table.  We bring recoverability, stability, accountability, etc.  And it’s quite possible that you start something on your own and then get IT involved when it gets too big or too important for you to manage yourself.  I really like this scenario because it’s often times easier for us to take over a project than it is to build it from scratch.  Sometimes it’s not because you have to re-write it to actually make it stable, but even that’s often times easier because you’ve already got the business logic and the GUI defined for you. 

So anyway, I like what I see in the demos on their new excel plugin (PowerPivot), but personally I’m waiting to see if it’ll actually work as well as they expect.  Because the data they’re using is highly specialized and I have to wonder how well my data will work with the product.  PowerPivot is a new BI plugin for excel 2010 but I really expect that it won’t really take hold for a couple yrs because the requirements to duplicate the scenario they outlined in the keynote are office 2010, sql server R2, and sharepoint 2010, and I just don’t see many people converting all of these that fast.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

Perfmon Scale

Here’s a picture of a perfmon session with 192 CPUs. This system was running SQL Server 2008 R2 which set a new benchmark. All of those tiny boxes represent separate CPUs and if you look really closely you can see the graph line inside some of them.

Bloggers’ Table

I’m sitting here at the bloggers’ table here at PASS listening to the announcements.  So far it’s just housecleaning, but Wayne is a good speaker. 

There’s been a lot of twitting this year and it really changes the face of the summit because you can find people and events just by pinging the group.  I didn’t think I’d like something like that, but it actually is pretty cool. 

I’m horrible at this live social blogging thing though so I’ll shut up now.

1st Night at PASS

Ok we arrived in Seattle for PASS only I found out tonight that I’m not supposed to call it PASS.  Apparently the PC name for PASS is the PASS Summit.  Oh well…

So we started at the Tap House wtih Allen White and his wife and then went to the convention center (I can still call it that, right?) to register.  There we met up with tons of other MVPs and a few people that Jen follows on twitter.  Would that be her fellow twits?

I was talking to Allen about how things appear to be getting better because there are a lot more MVPs here than there have been the past couple yrs.  I think this is going to be a good week.

We also did our first DBAs@Midnight with Allen.  It was really fun.  We got to talk about Oracle and making mistakes, and powershell, etc.  It was a fun talk.  I’ll upload it soon so check back and I’ll let you know when it’s up.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

PASS Treasure Hunt

Ok, so the MidnightDBAs are off to PASS next week and we’ll be giving away some of our recently designed swag.  The way this will work is we’ll be twittering our position from time to time and the 1st one to come up and find us will get a shirt, book, or something. 

So if you don’t already follow us in twitter, get yourself setup and have them delivered to your phone and just look for us out and about.

Good luck.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

Uniting at Last

The DBAs in my area have finally started using their connections through the user group in a way that will actually do them some good.  When they get an offer from a company they put the word out to the user group to get any info on that company that may do them some good in making their decision.  They typically ask what the company’s like to work for, what the bosses are like, what kind of vacation they get, if bonuses happen on a regular basis, if they expect you to work lots of overtime, what their work from home policy is like, etc. 

Personally, this is an excellent use of resources and I think companies have had it too good too long.  They way many of them just dump employees for silly, pathetic reasons because they know that it’s too much effort and cost to get a lawyer and sue so most people will just go get another job and forget about it.  Unreasonable demands on time and project guidelines are another favorite trick of companies when dealing with DBAs.  And they like to hold your head to the fire and then hold it against you when you get burned.  So maybe a little bad reputation will help to straighten them out. 

It’s always one of the hardest parts about starting a new job isn’t it… not knowing what you’re really in for?  So it’s really nice when you can ask someone who worked there before and get the full scoop before you take the plunge.  So I’d like to encourage all of you to keep it up and start working with the members of your user group to make sure that companies who don’t value their DBAs get found out.  So they’ll either change their ways or not get any quality DBAs.

Watch my free SQL Server Tutorials at:
http://MidnightDBA.ITBookworm.com

Read my book reviews at:
www.ITBookworm.com

Blog Author of:
Database Underground – http://www.infoworld.com/blogs/sean-mccown

Follow my Twitter:

http://twitter.com/MidnightDBA

Time off

Ok guys, I took a little time off of blogging to catch up on videos and MidnightDBA stuff, but I’m back now and I’ll be blogging more regularly again.

So if some of you haven’t heard yet, we’ve now got T-shirts on MidnightDBA and I’m rather proud of some of them.  We’ve got some other stuff too.  The main thing to remember with the shirts is to not take yourself too seriously.  We’re just having fun here and I hope you really like some of them.  We’re using Zazzle and you can find the link to our store here.

We’re not making much $$ off of them but what we do make will be going to fund our swag giveaways.

So go check out our store and find something you like.

I’ll have a more meaningful post tomorrow.

Instead of working, I blog.