Tuesday, July 14, 2009

No More Select *

Ok, not ‘no more’, but you guys should seriously limit your usage of select * for everything.  I realize that it’s easier to support when you change the data requirement, but it pushes a lot more data than you need and that could really impact network and server performance. 

Let’s say you’re running a web app and you need 3 cols on your page.  And you pull all 37 because it’s just easier to type a * than each column.  That’s fine from your end, but you could seriously impact the server and the network because if one of those cols is really wide, say varchar(200) (or even 400, right…) then you’re taking up that much extra bandwidth and server memory.  Sure it probably won’t effect your session that much now, but when you’ve got 500 people on your site at the same time you’ll start to feel the pain then for sure.

So just code for performance and stop being so lazy about having to type a few chars.  And if you really don’t like typing that much then get yourself a nice code completer like the one from Red-Gate and you won’t have to type nearly as much.  But I’m getting sick of laziness being an excuse for bad coding.

There are some exceptions though.  It is ok to use select * for some things but you have to choose those individually and judiciously.  Let’s say that you’ve got an SP that pulls 65 cols from a complicated set of logic that you don’t wanna have to re-create or maintain separately.  And let’s also say that you only need to query it every now and then, or maybe just 2-3 times a day.  In a case like that, it’s probably ok to go ahead and use the SP even though you’re only using a handful of the resultset.  However, in that same scenario, if you were using that data several times a minute, or even a second, then you’re really better off from a performance perspective to go ahead and create your own SP that returns less data.

Another excuse that gets used is people often tell me that they used select * to make it easier to make changes to the app.  And that is logical to a degree.  But people protect themselves all the time from issues that aren’t issues.  For instance, I had this just a while back where someone gave me that excuse and when I probed, the app had been up for 2yrs and had only ever had one minor change.  So what are you protecting yourself from then?  If the app is fairly static, then grow up and do the right thing.

OK, that’s actually stepping on the toes of another post so I’ll stop here.

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

 

Technorati Tags: ,

Monday, July 13, 2009

Just NO

No you can’t have a generic acct to share with all the devs in your dept so stop asking.

And Oprah.

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

Thursday, July 09, 2009

Midnight Twits

OK, like the rest of the world I have felt pressure to start twittering… so here’s my twitter addr, and feel free to follow me.  It’ll be mostly (if not completely) DB-related stuff so I’ll keep the personal stuff out.

http://twitter.com/MidnightDBA

 

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

There is no “I” in SHUT UP!

We’ve all had him… that manager who thinks he’s a wonderful team player but who is more like a Nazi than anything.

He thinks it’s teamwork to override everyone’s advice.

He thinks it’s teamwork to force people to work the way he wants to work that doesn’t make sense to anyone else.

He thinks it’s teamwork to have the minority opinion and force it on the group.

And of course he thinks it’s teamwork to monopolize every meeting with his own agenda(even someone else’s meeting).

So what do you do with someone when you can’t just tell them to shut up?  That’s a tough one and something we’ve all had to face.  At my last big gig there was a guy that none of us liked.  He literally sabotaged projects and he even swung a real sword around the office one day.  And for some reason the bosses wouldn’t get rid of him.  This guy was like the teflon don and nothing we did could get rid of him.  And that’s what I don’t understand.  What is it about these guys that the managers like so much?  Why do they consistently get rid of qualified techs and keep the morons?  Why does the guy with 3 kids who takes on every project in the place and produces more code than anybody get fired for an honest mistake when the little asshole who lives with his parents and is 4mos behind on his only project keeps his job?

I’m telling you, there’s something wrong with the American job marketplace.  Companies don’t know how to retain employees and they don’t care.  I really can’t tell you how many times I’ve been told by some HR tool that a DBA is a DBA and they can replace someone just like that.  Well you guys are probably all DBAs… does it really work like that?  Are we really all the same?  Can you just replace any DBA with any other DBA?  I really hope not because if that’s true then why did I even bother trying to get my MVP?  Or get my certs? 

OK, that was kind of a little jaunt there for a min… I was talking about dealing with that guy at work.

The truth is I don’t really have any of those answers.  It’s so hard to deal with someone like that because if you’re rude to him he’s the first one to go running to daddy to tell him you aren’t being a good soldier.  And now you look like the asshole.  And you can’t go to daddy yourself because now you look like a baby who can’t solve his own problems. 

Here are a couple ideas though.  These guys rarely act like themselves around the bosses so the bosses don’t know how they really are.  So you can start recording your interaction with them.  That’s a little underhanded and some companies don’t like that, but you can do it if it’s bad enough to prove a point and you need to prove to your boss that he’s unworkable.  Another thing you can do is to always make sure you talk to him with someone else present.  If you can, make it the boss.  Explain to the boss what this guy is like and that you want to hold all official meetings with him in the room to make sure you get heard and the right issues come out.  If you can’t always have your boss there, then whenever you have a meeting, send out meeting notes to him, the others involved and the boss.  In that email state that it was advised that he do this for these reasons and that he declined for this reason.  This way maybe the boss will read it and ask what happened, and at the very least you have a record so that when it all crashes, you’re covered.

Look, there is no real solution.  You just have to feel out the situation for yourself and see what it’s going to take.  It’s a shame that an inability to effectively deal with someone like that often times drives good people away.  I’ve worked in one company where they did regular 360 reviews and the managers looked through them and if someone got a low score from their peers they dug deeper.  And they often got rid of people based on those scores.  You have to be careful with something like that though.  Sometimes an entire group can hate someone just for doing the job he was hired to do.  So like an entire dev group can really hate a DBA coming in and locking down production when they’ve been allowed to do whatever they like for a long time.  And in a case like that they can use the 360 to get their power back… but I’m not bitter, I swear.

Technorati Tags: ,

Thursday, July 02, 2009

A Learning Plan

I realize it’s hard to find time to study with work pushing at you all the time and with family pulling on you after that, but you’ve gotta try to find some time or you’ll get left behind.

I’m certainly not perfect, but I am pretty good at making time every day to study something.  It’s not that hard really.  Just take 15mins out of your lunch break.  Or take 15mins at the end of the work day before you leave, or in the morning before you get started.  I used to spend the first 30mins every day going through newsletters, or reading a few pages in a book and going through an example.  It’s slow going to just do 15mins a day, but at the end of a month you’re further along than you would be had you not done anything at all.  Slow going is better than no going.

And I’ve interviewed guys before who were just pathetic.  You could tell that they hadn’t bothered learning anything new in a long time and even what they knew wasn’t all that.  And once I even got the opportunity to interview the same guy again like 2-3yrs later and you know what… he hadn’t changed a bit.  I don’t think he’d picked up a book in all that time.  And there’s just no excuse for not learning more these days.  There are so many free resources it’s staggering.  There are free sites with plenty of tech articles, there are free video sites, there are newsletters, forums, etc.  There’s just no excuse.

So really, don’t get left behind.  Dedicate yourself to 15mins a day.  Make it the same time every day.  It’s only hard to get started.  Once you’ve got the habit you’ll begin to love making even slow progress. 

Technorati Tags: ,