Monthly Archives: July 2011

Book Review: SQL Server Hardware by Glenn Berry

You probably only buy a couple of SQL Servers per year.  You probably just tell your sysadmins, “I need a 2-socket server with 32GB of memory,” and then you just assume everything’s okay.

Scratch that.  Let’s be honest.  It’s just us here, you and me, so I can be frank.  You don’t trust those bozos.  They sit around playing Capture the Flag while your server is down, and you’ve got a sneaking suspicion that they use your server as a BitTorrent host for a few weeks before they actually give it to you.  You’re lucky if it’s even got the right OS, let alone the right CPUs.

Yes, I used pink Post-It notes.

SQL Server Hardware by Glenn Berry

It’s time to take the problem into your own hands, and Glenn Berry is here to help.  Glenn, like me, is a hardware addict who loves reading Anandtech and digging through the details of the latest CPU architectures, memory configurations, and storage options.  Unlike me, Glenn wrote an entire book on the topic, all by himself, and this book kicks ass.  It’s everything you need to know to get the right hardware and get SQL Server set up correctly on it.

Hardware, Budgeting, and More

Let’s pick just one page.  Page 21 explains the difference in speed and quantity for all kinds of data – storage, memory, L3 cache, L2 cache, and L1 cache.  Glenn then explains why you care about each and how to pick the right CPU for SQL Server.  He finishes up (we’re still on page 21, mind you) by discussing why you might want to invest more in CPU power than memory – something that seemed blasphemous to me until I read his explanation, but now I’m sold too.

The book covers more than just hardware details, though: Chapter 6, SQL Server Version and Edition Selection, does a better job of explaining the business benefits of Enterprise Edition better than anything I’ve ever read.  Glenn gives a personal touch when he writes about each feature, and gives real-life hands-on-based advice about the feature’s worth.  For example, Distributed Partitioned Views sounds great in theory, but I’ve never seen it scale well.  Glenn points out why Data Dependent Routing is a better solution.  What, you haven’t heard of that?  Probably because it’s not a SQL Server feature – it’s a better way to design applications and databases, and it doesn’t require Enterprise Edition.  He doesn’t teach you how to do it, but like everything else in the book, he points you where to learn more about the topic.

The Bad News

I read books with a stack of Post-It notes at my side.  Whenever I see something that really surprises me – good or bad – I slap a Post-It note on the page with the edge just ever-so-slightly sticking out, and I jot notes on the Post-It.  I have this thing about not writing on books – probably comes from my childhood years spent at the library.  At the end of the book, I circle back and reread the tagged pages.  If there’s more good stuff than bad, I post a review on the blog.

Going back through this book, I only had one single negative Post-It.  Chapter 4, Hardware Discovery, explains how to use CPU-Z, MSINFO32, Task Manager, and Computer Properties to build an inventory of what your SQL Server is running on.  After reading that chapter, I was a little bummed that it didn’t explain how to gather an inventory of storage data, or how to get more in-depth hardware information from onboard management systems like the HP iLO or Dell DRAC.

But then it hit me: this is a 321-page book exclusively dedicated to evaluating, buying, and installing SQL Server hardware.  321 pages of technical goodness, and my only complaint is that it’s not long enough?  There’s never been a book like this before, and it’s a Herculean effort for anyone to pull off alone, and do it accurately.  Glenn pulled it off.  I didn’t find a single inaccuracy in the entire book, and believe me, that’s a rarity.  I even liked the cover photo of power plant cooling towers, a subtle joke about overclocked processors.

So if you ever need to spec out hardware for a database server, go buy SQL Server Hardware for under $20 at Amazon, read Glenn’s blog, and follow him on Twitter.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

The Mystery of Query Timeouts Video

“People are complaining about query timeouts. I don’t see anything happening in SQL Server, but they always say the database is the problem. How can I tell what’s really going on?”

When your users keep hitting timeouts in their application, they naturally think the database is killing off helpless queries. In this webinar Kendra Little will tell you how to triage treacherous timeout situations and collect hard evidence about whether or not the problem is in the database. Do the right detective work and you can turn your frustrated users and irate developers into raving fans.

This session is be 200-level – you should have familiarity with OLTP concepts and understand what DMVs and Profiler are, but you don’t have to be an expert with them.

Enjoyed the video? It’s part of our new Technology Triage Tuesdays, a free webcast series at 11:30AM Central every week.  Register for our next webcasts, and add a recurring calendar reminder.

Kendra Little

Kendra specializes in high availability and performance tuning. She is a Microsoft Certified Master in SQL Server-- the highest technical SQL Server Certification available. Kendra loves databases and software development more than long walks on the beach. Those cartoons in her blog posts? She draws 'em all. Read more and contact Kendra.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

How to Write a Conference Abstract

When I first started submitting abstracts to conferences, I wrote bland, technical descriptions of what I’d be talking about.  Later on, I thought being a good speaker meant having lots of people in my sessions, so I wrote spammy abstracts:

“SUNDAY SUNDAY SUNDAY!  COME SEE THE MOSTEST SPECTACULAREST DISPLAY OF SKILLZ EVER!  EVERY SINGLE DATABASE PROFESSIONAL – NAY, HUMAN BEING – SHOULD BE IN MY SESSION!  I PROMISE YOU’LL BE AMAZED AND DUMBFOUNDED AND BETTER LOOKING!”

One of my early presentations

One of my early presentations

Over time, I figured out that the goal of writing an abstract isn’t to get as many people into the room as possible.

The real goal of an abstract is to keep people out.

My abstracts need to communicate what I’m teaching, who should attend, and who should not attend.  When I’m communicating what I’m teaching, I try to use the coolest, most creative wording possible.  I use tricks from ProBlogger to craft appealing headlines and session titles, but that’s where the spam ends.  When I’m dealing with the last two needs – who should and shouldn’t attend – I lay things out in crystal clear language.

I know what you’re thinking, because I used to think the same thing: you think every single DBA should attend your session.  You think you’re going to craft a perfect balance of junior and senior material so that there’s something for everyone.  That rarely works, and instead, try to focus.  Focus is saying no.

Focus is picking exactly one person to be your target audience, and then completely satisfying that one person.  Figure out how to get that person into your audience, and how to keep the rest of the people out.  Let the others go see a session that’s more relevant for them, because if you don’t, they’re going to give you bad feedback.  They’ll say your material was too junior or too senior.  That doesn’t mean your material is bad – it means your abstract is bad, because it didn’t weed those people out of the audience to begin with.

To help, I’ve written a set of profiles for people who attend database conferences.  As you read these, think about whether they should sit in your audience.

Developer Profiles

The real goal of an abstract is to keep people out.Oliver Klozoff is a fresh-out-of-college developer.  He majored in Computer Science because he thought it’d make him rich.  He has no passion for technology – his skills are more C– than C++.  He lucked into his first job as a C# developer, is learning his way around Visual Studio, but he’s never opened SQL Server Management Studio.  His code barely works on his own machine, let alone in production, and he has no concept of whether the code is fast or slow.  He’s just finished his first application with LINQ and doesn’t understand why people think SQL Server is hard – mostly because he thinks LINQ handles it all for him.

Seymour Butz’s business card says he’s a Senior Developer, and that’s mostly true.  He’s got five years of experience, but he’s the only developer at his shop who hasn’t quit due to the abusive managers.  He enjoys what he does, reads programming blogs every now and then, and does a pretty good job of catching exceptions in his code.  He can identify when a query is running slow, and he’s comfortable adding tables and views in SSMS, but he relies on the Database Tuning Advisor to add indexes for him.  He doesn’t know whether 10 indexes on his tables are good or bad, but he’d like to learn.

Amanda Hugginkiss is the sharpest of the C#.  She’s one of those people who was born to develop.  She was contributing to open source projects before she got her high school diploma, and by the time she dropped out of college, she’d coded for three different startups.  She documents her code even though it explains itself, and she writes unit tests before she starts coding.  She knows when to use LINQ, when to switch into stored procedures, and how to read a basic execution plan. Every employer wants Amanda Hugginkiss.

Database Developer Profiles

Mike Rotch used to be a Java developer, but he gradually moved into database development.  His company builds Java apps with a SQL Server back end (yes, it actually happens) and he was always the first guy to understand whether problems were due to Java or the database.  It’s not that he’s a SQL pro – he’s just naturally curious, enjoys learning, and knows how to use Google.  He’s process-oriented: when there’s a problem, he troubleshoots methodically.  He’s comfortable writing T-SQL, reading execution plans, and makes good judgment calls about when to add an index or when to fix the query.

Jacques Strap is the kind of guy you want around when things start to get dangerous.  He’s fresh out of the field – well, maybe “fresh” would be the wrong word.  Let’s be honest: his code smells.  He used to be a salesman, but he kept writing more and more Crystal Reports for the sales managers, and next thing you know, his stuff was all mission-critical.  He understands what data means to the business, and he’s able to think like a user.  He knows how to prioritize, which is good and bad: his first priority was satisfying the business report needs, and his last priority was making it run fast.  As a result, he’s got thousands of lines of T-SQL in production stored procedures, but none of them are quick.  Nevertheless, he’s got a never-say-die attitude, and the business people love him.  He wants to look like a hero in their eyes.

Database Administrator Profiles

Hugh Jass was working happily in his cube as a systems administrator for years until the company decided to buy SharePoint.  They handed him the DVDs, told him to get it implemented, and didn’t give him any training or consulting budget.  He did typical Microsoft installs – setup-next-next-next-finish – and things started humming along.  He turned his back, and next thing you know, he’s an accidental DBA, and all 1,000 company employees are storing documents in SharePoint.  He isn’t comfortable in SSMS, let alone T-SQL or DMVs, but he knows the bejeezus out of hardware and Windows.  He knows there’s a problem because CPU is averaging 95%, the hard drives are smoking, and the users are whining, but he doesn’t understand what’s going on inside the black box of SQL.

Drew P. Wiener loves to say that he’s got ten years of experience as a DBA, but what he doesn’t realize is that it’s the same one year over and over.  He’s been managing the same twenty SQL Servers the whole time, not really improving anything dramatically, just making sure the trains run on time.  He’s got one cluster and one transactional replication setup, so he puts clustering and replication on his resume, but he doesn’t really understand what makes them tick or how to fix them if they explode.  He’s perfectly comfortable with T-SQL, but hasn’t learned the new stuff like CTEs or TVPs – he just doesn’t know what he doesn’t know.

Panel Discussion

Panel Discussion

Ivana Tinkle can take a quick look at a server and have a pretty good idea of what’s going on.  She’s mastered Ozar’s Hierarchy of Needs, and now she’s teaching her junior DBAs how to do the same.  All her servers are well-protected, stable, and part of a master plan.  She attends one or two conferences per year, and she’s getting ready to put on her first presentation for the local user group.  She knows what she knows, and knows what she doesn’t know – but she’s on a mission to reduce the latter.

Manager Profiles

Yes, managers actually attend conferences.

Rolo McFlurry is a sweet, lovable guy who means well, but he’s incredibly destructive.  He knows enough to be dangerous, and he doesn’t know just how dangerous.  He kills SPIDs when they block his queries, remembers the SA password because it’s the same as the Windows admin password, and he violates all the standards while he tells his DBA team to enforce them.  He hasn’t even begun to track metrics like uptime or data size.  He just wants the CEO’s reports to run fast, and he wants to go home at 5:00 PM.  He attends conferences to get out of the office, and whenever he sees the presenter doing something, he’ll try the exact same thing in production when he gets back.  He loves pointing out how the MVP presenters all run as SA, so why shouldn’t he?

Ollie Tabooger spent years in the trenches, working his way up as a database administrator at a global financial firm.  After fifteen years of dedicated service, managing first Sybase, then SQL Server, then a little Oracle too, he became a team manager.  He has a dozen very talented direct reports who all respect his dedication and technical prowess.  He attends conferences to see what’s coming next, to learn new tricks to manage SQL Server at large scales, and to network with vendors who all want to get into his pants.  (For his wallet, you understand.)  He likes sessions that explain the why, but not the how – he hates seeing demos.

The Moral of the Story

Don’t ever, ever, ever say your session has something for everyone.  You might get a lot of attendees, but your evaluations will be spectacularly poor because the attendees will feel like you wasted their time.

If you liked this, check out How to Deliver a Killer Technical Presentation, Dealing with Presentation Criticism, and How to Pick Blog & Presentation Topics.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Just One More Thing… Introducing CorrugatedIron

I like to share what I know. That’s why earlier this year, I contributed some code to the Riak function contrib. Since then, I’ve been quietly becoming an independent consultant, starting a business, and working on a big chunk of code. I’m proud to release to the world CorrugatedIron.

More NoSQL for .NET

If you’ve been paying any attention at all (please say you pay attention to me), you’ll have noticed that I like to find fun and interesting ways to use and abuse data. You’ve also noticed that a lot of my interest lies in Riak. When I discovered Riak, there was a very good Ruby library, Ripple, some Java and Erlang libraries, and two .NET libraries that seemed a bit dead in the water.

I saw a lot of promise in Riak – it’s a distributed key/value database and it’s incredibly fault-tolerant. But the downside for many developers, especially developers who work with the Microsoft stack, was that there was no good way to connect to Riak. What that really means is that there was no good way for me to bring Riak to the masses of Microsoft developers and IT pros. Luckily, I had a plan.

I Love It When a Plan Comes Together – Developing Corrugated Iron

Through the Basho folks, I got in touch with OJ Reeves. OJ had started work on a C# library for Riak. Well, he’d started in his head. We emailed back and forth (he has an interesting take on the exchange), and nothing happened. I started a company, he had barbecues and ate shrimp with people named Bruce. In April, we decided to stop slacking off and write some software.

We wrote code quickly and threw it away even faster. We wrote and broke unit tests daily. Interest grew and we decided that we needed a date. We chose July 25th – it’s the first day of OSCON and it was a hard and fast date to get software out the door.

Throughout the development process, OJ and I have joked about strong opinions held loosely. Change is good, challenge is good; having a healthy respect for each other is good. Working with a developer on another continent taught me a lot about evaluating ideas, careful communication, and my own skills as a developer. OK, some of that’s a lie. There were many emails, Skype chats, and pair programming sessions via Webex, but through it all we maintained a respect for each other and a willingness to build and tear down code as many times as necessary to make a feature work.

Where is CorrugatedIron Now?

The whole idea behind CorrugatedIron is to make it easier for .NET developers to use Riak in their applications. SQL Server does many things really well, but there are some things that RDBMSes just aren’t good for. CorrugatedIron opens up choices for .NET developers.

The documentation isn’t where we want it to be and the code isn’t tested as thoroughly as we’d like, but we have working samples. I put some working into building a Session State Provider for ASP.NET (a great use of Riak, by the way) and OJ wrote several sample applications and configuration samples.

What Does It Mean To Me?

I’ve enjoyed working on this project for a few reasons. It’s given me the chance to write code outside of SQL Server. I didn’t realize how rusty I was with C# until I started working on CorrugatedIron. After a few weeks I was right back into it and I’ve been slowly working my way through many of the topics that I missed over the last few years. The best way to learn something is to do it.

The other big reason, for me, is giving something back. I’ve used open source software a lot throughout my career. While I can’t give back directly to many of the projects I’ve worked on, I’m able to give back by writing code and sharing it with the world.

What Next? ###

If you want to get started with CorrugatedIron, or you think you might know a developer who’d like to experiment, grab the source, download some binaries, install the NuGet package, and write some code. This is open source, so if there are missing features, issues you’re running into, or problems you’re having, hit us up on github, fork the repository, and get contributing!

Jeremiah Peschka

Jeremiah Peschka has worked as a database and emerging technology expert at Quest Software where he researched new trends and technologies in the world of data storage. Over the course of his career he’s worked with companies across many industries as a system administrator, developer, and DBA. He’s been involved with all aspects of application development and deployment. He likes cheesecake, coffee, and ice cream.

More Posts - Website

Follow Me:
TwitterFacebook

How to Be a Superstar: Change a Few Well Placed Things That Make a Difference

There’s a few things about creating a luxury experience that apply to the daily work of database administrators, developers, and general programmers. I worked this out last week when I did some spring cleaning.

Things I Learned from Cleaning the Bathroom

I noticed something when I cleaned the upstairs bathroom: I’d put in a lot of work and scrubbed almost everything. It looked clean enough. Then I cleaned the chrome circle around the bathroom water faucet and the faucet itself.

I stepped back and the bathroom no longer looked clean enough. It looked awesome. There’s something about the shine on chrome and a large clean faucet. The floor could have been a bit dirty, and that bathroom would still have looked awesome.

Life is Like This

This is how the world goes– you can clean the toilet and the floor again and again and it’ll look OK. Those basics are needed, but they don’t make something feel fantastic to whomever uses the bathroom.

It’s a few well placed smart things in the midst of a good-enough environment that make a user feel like they’re using something really special.

Let’s break this down:

A Few

You don’t have to make everything awesome. You shouldn’t really– you should make a few things awesome for your customers. If everything is shiny and full of complexity, your customers will be overwhelmed and confused. Worst of all, you’ll be so irreplaceable that you can never be promoted.

If you’re a DBA, this means you don’t offer highly complex and detailed explanations of all of the settings and configuration to your management or the help desk. You offer summary information and aggregate performance data, and identify a few key places to give rich, complex information.

If you’re a developer, this doesn’t mean that you always write perfect code. But it may mean that you write a cool add-in to automate documenting code.

If you define the feature set for applications, this means you don’t include every feature customers ask for. Instead, you keep the overall interface simple, and carefully select the features that will be the most effective long term.

Well Placed

Pick something noticeable and meaningful. Talk to your customers and peers about what they currently see as important. Ask them questions about how their processes work. Listen carefully.

Listen for what might simplify their life and their process, what you might be able to do to save them time.

If you talk to several customers and peers, you’ll find patterns. Don’t promise everyone everything– what you’re looking for is a couple good places to focus. These places are something where you can add a feature, develop a tool, write a report, or provide deep information. If you’re in a large organization, it might just be a way that you can bring two teams together so they can help each other without your assistance. They key is that it needs to be noticeable: it needs to be something that makes a difference.

Smart Things

You’re looking for a place where you can shine. You need this to be a “smart thing”. This means it needs to be something people can easily describe. You need a quick name to describe your contribution that sounds cool in your company culture.

Depending on your workplace, this might mean coining an acronym, making a code name, or just using industry terminology. But you want something short and memorable.

Here are some examples of names you might introduce for your features:

  • The Activity Tracker: a daily report on the total inserts, deletes, and selects on critical tables.
  • The Build Watcher: a utility for the nightly build that does x (there’s a myriad options of utilities you can do for your builds)
  • The Hall Monitor: a utility that tracks changes in permissions granted to databases.

A Good-Enough Environment

While you’re finding a few achievements you can create in your job that create a great experience for your customers, you don’t want them to often be horrified by using basic services.

This can be tricky. What if you’re greatly understaffed? What if things beyond your control are a mess, and constantly make your customers unhappy?

To some extent, this is always true in all our jobs. There’s always a few things that aren’t perfect which cause problems for people, but the costs to fix them are so high that they don’t get tackled.

What you need to do is to figure out how to get a good-enough general experience for your customers. When big problems surface, talk to them with your customers. Don’t contest whether there is a problem– be open about the situation and the costs of changing things. You want your customers to understand that you listen to them. This will help them understand when the problem is out of your scope.

If the environment has repeat failures or causes critical situations for your customers, use these conversations to identify your “smart things.” Create a few smart things that help manage around the failures. Create a tool that supports workarounds. Scope your plans for a few things that will improve usability, and you’ll still become a superstar.

Being Part of Something Really Special

Success in the modern workplace is creating an environment where you feel like you’re part of something really special– and so do your customers.

You don’t achieve that by bringing in unicorns and rainbows. You make yourself successful by being a great team member, and by making yourself known for a few special, noticeable, key things.

I’ve been there, and I’ve done it– I just didn’t always know exactly what I was doing. It took cleaning a bathroom to really figure it out.

Kendra Little

Kendra specializes in high availability and performance tuning. She is a Microsoft Certified Master in SQL Server-- the highest technical SQL Server Certification available. Kendra loves databases and software development more than long walks on the beach. Those cartoons in her blog posts? She draws 'em all. Read more and contact Kendra.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Land a Dream DBA or Developer Job: Seven Questions to Ask

Looking back over all my years of interviewing and being interviewed, I realize that there are simple secrets to getting a great job offer.

The big secret is just this: ask great questions.

Interviewing Goes Both Ways

Asking thoughtful questions in your interview process, from screening to salary negotiations, makes you more powerful. It shows you’re engaged, informed, and in control of your career.It's easy to remember a great engineer.

A candidate who asks good questions automatically demonstrates that they’re selective, and they have choices.

But what do you ask? Here’s a checklist to go through before each interview to develop questions and remind yourself what to emphasize by your questions. By all means, write down your questions and take them with you.

1. Be the Candidate Who Loves to Learn

Ask at least one question about technology you’re unfamiliar with. Find out what technologies are in place at your potential job before an in-person interview and do an hour of research on those you don’t specialize in. When it comes up in the interview make it clear that you were inspired by the interview process to start learning.

Don’t pretend to be an expert in fields you don’t know about. Do be honest about your interests and show you have initiative. Ask questions about challenges they’ve hit and what informed their design and implementation decisions.

Before your interview, make notes on times when you faced a difficult task, learned something new, and were able to improve something. You’ll likely be asked questions about your experiences when you can tell your stories.

2. Ask At Least Two Smart Technology Questions

Most candidates just ask basic questions about what versions of software are running. This is a great chance to set yourself apart.

  • What are their pain points? This is something we care a lot about at Brent Ozar PLF, but we don’t mind sharing our mojo with you for your interview. This is the most interesting question you can ask: tell me where it hurts in your technology. You’ll want to get lots of detail on this. Make notes and follow up on different points they cover. Ask this question of different people throughout a day of interviews and compare the responses. I promise it’ll be interesting.
  • Are they leveraging their strengths? When you’re familiar with the products they’re using, think about the strengths of that product. Ask a question in a way that shows your knowledge. If you know that the JurgenPlufen can provide high availability when clustered, then ask if they’re doing that. If they aren’t, ask why– the reason will let you know a lot about their business. Keep your tone curious, not judgmental.
  • What major changes have they made? Over the history of the company, are there any revolutions in technology they can tell you about? How did they handle that change, and what would they do differently now?
  • Are they open to other technologies? This matters more to some people than others, but it’s an important thing to know. Is this a company that looks for the right tool to solve an individual problem, or do they prefer to standardize to narrow the scope of support? There are pros and cons to both ways, but you need to know which way they go in order to see how you fit in.
  • Have they tried the New Hotness? This is something you want to be a little careful with, unless you’re always about the new hotness and it’s important to work for someone who’ll support that. But if they describe a problem and you think there’s a fairly obvious newer product they could by or upgrade they could make to support that, ask about it. You want to find out why they haven’t gone there– are they slow to adopt? Short on people? Short on budget for new technologies?
Good questions show you’re not only a skilled technician. You’re an engineer who takes the initiative to find out how to improve an environment.

3. Ask A Question About Process

You want to know what processes are in place at a prospective employer. You also want to show that you’re responsible.

As a candidate for DBA positions I made it a habit to ask during phone screens, “Can you tell me a bit about your change management processes?” More often than not, IT hiring managers were thrilled that I’d asked. When I asked follow up questions it was clearly hard for them to sit still.

Focus on exploratory questions– don’t be critical. For a later interview, you should think about scenarios you might be in and create a hypothetical question. “What if we decided to change the Yak so that it had air conditioning? Can you walk me through what the process of making that change would be like here?”

Be ready in case the question is turned back around to ask what YOU would recommend— that should be a home run.

4. Ask About the Business

Before you ever talk to the company look for technical blogs, or any blogs written by employees. These are a great source for information about how things work at the company, and also a great source for questions.

It's good to ask about what's important. But not just about tuna.

This is what the competition is asking.

Always check out recent news articles for the company as well. Care about the industry. Make sure you have a few good questions about that market and where the company is going– if you make it to higher level interviews with executives, these will be particularly useful. If you don’t have much experience in that industry, it’s perfectly fine to ask questions like, “I haven’t worked for a dairy but I’ve read there are three major players. As a smaller company, how do you position yourselves in the milking industry?”

Your overall goal is to show you’re not just a technologist, you’re a potential invested employee.

5. Ask A Question that Shows You Listen

On a full day of interviews, you will be able to take information you get in one interview and use it to ask questions of other people. This is one of the great reasons to take notes in your interviews.

Be careful that your questions don’t seem to pit people against each other, or slight the previous person you talked to. You want to ask questions more like, “Harriet described the asynchronous processing she designed for the Femisphere system. Can you tell me how that works from an operational perspective?”

This shows you listened to Harriet and absorbed some of the concepts she discussed. Not everyone can do that! If you have follow up questions ready because you understand some of the operational challenges in the area, you’re in the catbird seat.

6. Ask A Question That Shows Your Strengths

Sometimes people ask what your greatest strengths are, sometimes they don’t. Figure out what your greatest strengths will be for that position, but do it so you can ask the right questions.

Let me get one thing straight: this isn’t BS. You want to pick a few real things that set you apart and make you satisfied about work.

Here’s some example questions:

“I like to identify big changes and drive them to completion in an active production environment. Is this a place where that’s encouraged? What are the barriers to large changes? What support is available?” Big changes work much better in some companies than others, and you want to know if you’ll always be holding your horses, or if you can make things happen. (If you ask this question, have two stories of how you’ve done this in the past ready.)

“I really enjoy specializing in certain areas of NERDERY and diving deep. This means I like to take four hours a week to do research. I can document what I learn and present it to the team. Would people be interested in that?”

“I am a generalist and I really enjoy reaching out to other teams and working out how components integrate. For example, would I have access to the configuration of the Gigabiggers and is their team open to having me sit with them once a week to learn about what they do?”

A question like this shows self-awareness, and it will tell you a lot about whether you’re going to sink, swim, or run for shore in that environment.

Practice, Practice, Practice

Interviewing is a bit like swimming. At first you have no idea how to do it, but you get thrown in the water and you learn it to survive. If you never practice then your technique suffers.

If you haven’t interviewed in a while or if you are changing industries and are not sure how you’ll do, ask for help. Get connected with bloggers or people in the industry on Twitter. Go to a user group. Ask people if they would be willing to do a 45 minute practice interview with you as the candidate. Listen to their feedback. When you practice, make sure you’re asking them questions as well as responding to questions.

Don’t be afraid to go on multiple job interviews. The downside is that interviewing is hard work, and it’s unpaid. The upside is that you can learn a ton, make great connections, and also find that you’re better at a lot of things than you ever realized.

Did You Land That Dream Job? What did You Ask?

I’d love to hear about your experiences as candidates and about the questions you asked. Did these make a big difference in your interviews? Do you feel that your questions set you apart from the competition?

Kendra Little

Kendra specializes in high availability and performance tuning. She is a Microsoft Certified Master in SQL Server-- the highest technical SQL Server Certification available. Kendra loves databases and software development more than long walks on the beach. Those cartoons in her blog posts? She draws 'em all. Read more and contact Kendra.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

Completely Legal SQL Performance Enhancements Video

In this video, Jeremiah Peschka talks about the basics of persisted computed columns, indexes, 64-bit servers, and statistics – all free ways you can get more performance out of your existing hardware.

Here’s Jeremiah’s links for the webcast resources.

Enjoyed the video?  It’s part of our new Technology Triage Tuesdays, a free webcast series at 11:30AM Central every week.

Next Tuesday: Kendra Solves the Mystery of Query Timeouts:
First Steps for the Database Super Sleuth

“People are complaining about query timeouts. I don’t see anything happening in SQL Server, but they always say the database is the problem. How can I tell what’s really going on?”

When your users keep hitting timeouts in their application, they naturally think the database is killing off helpless queries. In this webinar Kendra Little will tell you how to triage treacherous timeout situations and collect hard evidence about whether or not the problem is in the database. Do the right detective work and you can turn your frustrated users and irate developers into raving fans.

This session will be 200-level – you should have familiarity with OLTP concepts and understand what DMVs and Profiler are, but you don’t have to be an expert with them.

Register for our next webcasts, and add a recurring calendar reminder.

Jeremiah Peschka

Jeremiah Peschka has worked as a database and emerging technology expert at Quest Software where he researched new trends and technologies in the world of data storage. Over the course of his career he’s worked with companies across many industries as a system administrator, developer, and DBA. He’s been involved with all aspects of application development and deployment. He likes cheesecake, coffee, and ice cream.

More Posts - Website

Follow Me:
TwitterFacebook

Building a Better BrentOzar.com Blog

I’m so proud. My baby’s all grown up now.  When I started BrentOzar.com more than ten years ago, I never would have dreamed it’d turn into a consulting company, but here we are.  Getting from Point A to Point B is hard as hell, though, so today I’ll give you a peek behind the scenes at some of the stuff we’ve been up to lately.

Adding Pull Quotes

I love to dress up – my blog posts, that is.  Pictures are good, but for years, I’ve wanted to do pull quotes: standalone sentences that pop out visually from the rest of the text.  They grab a reader’s attention, show off your fancy punchlines, and save them from the tedious monotony of your boring writing.  Some posts just don’t lend themselves well to pictures, and sometimes you’re just really proud of a particular line.  (No, I’m not proud of most of the lines I write here.  In fact, I’m going to go cower in shame right now.)

There’s a really good WordPress plugin for pull quotes, but it doesn’t work for people who subscribe to the blog via RSS or email.  We’ve got thousands of RSS and email subscribers, so that wasn’t good enough.

Or at least, mine.Out of nowhere, Kendra Little (b|t) emailed a picture of a magazine article to discuss the typography layout, and it hit me – I could use pictures of text instead.  Hard-core web designers will point out that using pictures of text is very bad form: the text isn’t searchable, doesn’t work with screen readers, and kills kittens.  I’m not really a cat guy, and the text doesn’t really need to be searchable, and the results are just so damn gorgeous.

To create image-based pull quotes, fire up your picture editor of choice (Photoshop, Gimp, or MS Paint for the Access guys) and lay out your text.  Save it as a PNG (gets you image compression with minimal loss) and upload it just like any other picture you’d use in your blog editor.  Presto, beautiful pull quotes.

With this method, you can use any font and layout without the hassles of CSS and web-friendly fonts.

Refining Past Posts and Combining Series

Through a lot of careful analysis, I’ve learned that multi-part series posts just don’t work well over time: people randomly stumble upon a single article in the series, but they don’t start at Part 1 and click all the way through the end. I fixed this by combining the posts: I take the Part 1 post, merge the other blog posts into it with copy/paste (yes, I plagiarize my own work) and turn Part 1 into a comprehensive, long post that covers the subject start to finish.

Between combining posts and refining & expanding content as described in my post how to find buried treasure with Google Analytics, I’ve put a lot of work into some of my past stuff. A few examples include:

On some of those pages, I went so far as to embed a contact-us form with Contact Form 7 directly on the page.  This represents another step in the evolution of BrentOzar.com.  In the beginning, I begged people to contact me.  Years later, I ripped out that wording because I was getting overwhelmed with homework questions, and just let people leave comments when they were really struggling.

These days, since we offer consulting services, we’re trying to gracefully offer help where we can.  If somebody has a question we can answer in 5 minutes or less, generally we just do it for free.  If it’s something that would take an hour of dialog, we need to bill for that.  The stuff in between is probably best handled on sites like StackOverflow.com and DBA.StackExchange.com.

Another Social Media Experiment

Social Media Buttons

We’d tried social media toolbars like Wibiya before, and I just wasn’t impressed.  Web site metrics didn’t improve (although we did get a big rush of Facebook fans) and the toolbar looked spammy.  However, with the launch of Google+ and Facebook Video Chat, we decided to give social media buttons another shot.  We added the Twitter, Facebook, and Google +1 buttons right under the post titles.

Did it work?  I’m not sure yet – this one’s too early to tell right now, but early results from Backtweets look positive.  I’ll keep an eye on the metrics and see if it matters.

Public List of GoCodes

When we work with clients, some issues pop up really frequently.  I constantly have to refer people back to certain posts.  Rather than trying to remember some obscure URL or hoping that an outside link service doesn’t go down, I used the WordPress GoCodes plugin to create my own list of useful short links.  This way, when someone wants to learn more about how to do backups, I can just say, “Go to BrentOzar.com/go/backup and I’ve got my best practices and posts on there.”

This set of specialty landing pages is something I’ll be putting more work into over time.  We write a lot about our favorite topics, and we need to group together our best past posts by topic into a single resource page per topic.

Added Author Info Section

BrentOzar.com has four authors now, but we kept getting confused readers complimenting me for a post that someone else wrote.  The sweet WP About Author plugin fixes that elegantly by adding the post’s author profile to the bottom of every blog post:

WP About Author Plugin Profile

It even works on the main page of the blog, and you can customize which pages show it.  On a single-author blog, you probably only want it on your single-post pages.  That way, when people arrive at your post via a Google search, they learn a little more about you and might remember you by name later.

The one drawback is that it doesn’t show up in the RSS feeds.  <sigh>  A blogger’s work is never done.

Brent Ozar

Brent specializes in performance tuning for SQL Server, VMware, and storage. He's one of the very few Microsoft Certified Masters of SQL Server, a published author, and a Microsoft MVP. He likes travel, Jeeps, Apple gear, jokes, and writing about himself in the third person. Read more and contact Brent.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube

The Difficulty with Deadlocks

Deadlocks can kill an application’s performance. Users will complain about the app being slow or broken. Developers will ask the DBA to fix the problem, DBAs will push the problem back on developers. The next thing you know, the office looks like Lord of the Flies.

What is a Deadlock?

A deadlock occurs when two queries need exclusive access to different tables and each query is waiting for the other to finish. Assume that there are two tables, tA and tB. There are also two queries, Q1 and Q2. The first query, Q1, takes an exclusive lock on tA at the same time that the second query, Q2, takes an exclusive lock on tB. So far, there’s nothing out of the ordinary happening. Q1 then requests exclusive access to tB. At this point we have a block. Q1 must wait for Q2 to release its lock before Q1 can finish. Q2 now requests an exclusive lock on tA. And here we have a deadlock.

Q1 won’t release its lock on tA until it can get a lock on tB. Q2 won’t release its lock on tB until it can get a lock on tA. In order for either query to finish, they need access to the other query’s resources. That’s just not going to happen. This is a deadlock.

In order for the database to keep responding, one of these queries has to go. The query that’s eliminated is called the deadlock victim.

Finding Deadlocks

What is the first sign of a deadlock? Queries that should be fast start taking a long time to respond. That’s the first sign of a deadlock, but that’s also the first sign of a lot of other problems. Another sign of a deadlock is an error (error 1205 to be precise) and a very helpful error message: Transaction (Process ID %d) was deadlocked on {%Z} resources with another process and has been chosen as the deadlock victim. Rerun the transaction.

SQL Server is telling you exactly how to solve the problem – re-run your transaction. Unfortunately, if the cause of the deadlock is still running, odds are that your transaction will fail. You can enable several trace flags to detect deadlocks (trace flag2 1204 and 1222), but they output the deadlock to the SQL Server error log and produce output that is difficult to read and analyze.

Once deadlocks show up, your database administrator might reach for a script to pull deadlocks out of Extended Events. Extended Events are a great source of data for analysis. Although they’re a relatively new feature to SQL Server, they first appeared in SQL Server 2008, Extended Events already provide an incredibly rich set of tools for monitoring SQL Server. Event data can be held in memory (which is the default) or written out to a file. It’s possible that to build a set of monitoring tools that log all deadlocks to a file and then analyze that file after the events happen.

Yesterday's deadlocks are tomorrow's news!

Just like newspapers help us find out what happened yesterday, Extended Events provide a great way to investigate deadlocks that have already occurred. If you don’t have any other monitoring tools in place, Extended Events are a great place to start. Once you start seeing deadlocks, you’ll want to start gathering more information about them. It takes some skill to read the XML from a deadlock graph, but it contains a great deal of information about what happened. You can find out which tables and queries where involved the deadlock process, which process was killed off, and which locks caused the deadlock to occur.

The flip side of the coin is that Extended Events will give you very fine grained information about every deadlock that has already happened. There’s nothing in Extended Events to help you stop deadlocks from happening or even to detect them right when they are happening. Much like a microscope lets you look at a prepared slide in excruciating detail, Extended Events let you look at a single point in time in excruciating detail. You can only find out about things after they happen, not as they happen.

Deadlock Notifications

Wouldn’t be nice if you received notifications of deadlocks as they were happening? Good news! Deadlocks only happen when data is changed; it’s possible to wrap your modification statements inside a template to record any deadlocks that happen. This template takes advantage of some features in SQL Server to allow the deadlock notifications to get sent out asynchronously – the notifications won’t slow down any applications while they interact with SQL Server.

There is a big problem here: every stored procedure that modifies data needs this wrapper. If the wrapper is missed in one place, there won’t be any deadlock information collected from that query. If the wrapper needs to be changed, it has to be changed everywhere. This can be a good thing, of course, because you can target problem queries for reporting or different queries can respond in different ways. Like using Extended Events, this is a very fine grained mechanism for dealing with deadlocks. Action is taken at the level of a single execution of a query and not at the level of our entire application. If we’re going to take care of deadlocks, we want to do it once and fix things across the entire application.

Deadlocks by Design

Both the Extended Events and notification solution are very cunning ways to get information about deadlocks that have already happened. Neither solution helps applications respond to deadlocks as they happen.

Much like a director deciding to fix it in post, monitoring for deadlocks and trying to solve the problem is a reaction to something that should have been done right in the first place. Maybe budget constraints got in the way, maybe the software had to ship by a deadline, maybe there wasn’t expertise on the team to look into these problems. For whatever reason, something made it into production that causes deadlocks. It doesn’t matter what happened, the problem is there; deadlocks are happening.

Error 1205: Catching Deadlocks with Code

Application developers have tool they can use to cope with deadlocks. When SQL Server detects a deadlock and kills of a query, an error is thrown. That error makes its way back up to the software that made the database call. .NET developers can catch the exception and check the Number. (Deadlocks throw an error number of 1205.)

When a deadlock happens, SQL Server will kill off the cheapest transaction. The “cheapest” transaction is the transaction with the lowest cost. It’s getting rid of something that will be easy to run a second time around. Instead of having deadlocks cause problems, developers can easily check the errors that come back from the database server and try again. You can set the deadlock priority; if you don’t have time to fix to the code, you can specify which queries should run at a lower priority.

This is moving the problem up the chain. The users may not see that there is a deadlock, but the application code still needs to deal with it. Things can still be tricky, though. If there’s a long running transaction holding locks and causing deadlocks, no reasonable amount of re-tries will solve the deadlocking problem.

Reacting to Deadlocks with Architecture

The easiest way to eliminate deadlocks is to design the database to avoid deadlocks. It sounds facetious, doesn’t it? Of course the easiest way to avoid deadlocks is to design so they don’t happen!

There are a few architectural patterns to use in an application to avoid deadlocks.

Pattern 1: Using NOLOCK to Stop Deadlocks

NOLOCK for YESOUCH

A common way to stop deadlocks is to use the NOLOCK query hint. NOLOCK users advocate this approach because they believe it does what it says – it eliminates locking.

NOLOCK doesn’t get rid of all locks, just the ones that make your queries return the right results. You see, NOLOCK stops locking during read operations. In effect, it throws the hinted table or index into READ UNCOMMITTED and allows dirty reads to occur. Locks are still necessary for data modification; only one process can update a row at a time.

By using NOLOCK, you’re telling the database that it’s okay to avoid locking for read safety in exchange for still letting deadlocks happen.

Pattern 2: Indexing for Concurrency

In some cases, deadlocks are caused by bookmark lookups on the underlying table. A new index can avoid deadlocks by giving SQL Server an alternate path to the data. There’s no need for the select to read from the clustered index so, in theory, it’s possible to avoid a deadlock in this scenario.

Think about the cost of an index:
* Every time we write to the table, we probably end up writing to every index on the table.
* Every time we update an indexed value, there’s a chance that the index will become fragmented.
* More indexes mean more I/O per write.
* More indexes mean more index maintenance.

To top it off, there’s a good chance that the index that prevents a deadlock may only be used for one query. A good index makes a single query faster. A great index makes many queries faster. It’s always important to weight the performance improvement of a single index against the cost to maintain and index and the storage cost to keep that index around.

Pattern 3: Data Update Order

A simple change to the order of data modifications can fix many deadlocks. This is an easy pattern to say that you’re going to implement. The problem with this pattern is that it’s a very manual process. Making sure that all updates occur in the same order requires that developers or DBAs review all code that access the database both when it’s first written and when any changes are made. It’s not an impossible task, but it will certainly slow down development.

There’s another downside to this approach: in many scenarios, managing update order is simply too complex. Sometimes the correct order isn’t clear. Managing update order is made more difficult because SQL Server’s locking granularity can change from query to query.

In short, carefully controlling update order can work for some queries, but it’s not a wholesale way to fix the problem.

Common Patterns: Common Failures

One of the problems of all three patterns is that they’re all reactionary. Just like the two methods for detecting deadlocks, they get implemented after there is a problem. Users are already upset at this point. There has already been some kind of outage or performance problem that caused the users to complain in the first place. Of course, sometimes you inherit a problem and you don’t have the opportunity to get good design in place. Is there hope?

Whether you’re starting off new design, or combating existing problems, there is a way that you can almost entirely prevent deadlocks from occurring.

Using MVCC to Avoid Deadlocks

MVCC is a shorthand way of saying Multi-Version Concurrency Control. This is a fancy way of hinting at a much broader concept that can be summarized simply: by maintaining copies of the data as it is read, you can avoid locking on reads and move to a world where readers never block writers and writers never block readers.

This probably sounds like a big architectural change, right? Well, not really.

SQL Server 2005 introduced READ COMMITTED SNAPSHOT ISOLATION (RSCI). RCSI uses snapshots for reads, but still maintains much of the same behavior as the READ COMMITTED isolation level. With a relatively quick change (and about a 10 second outage), any database can be modified to make use of RCSI.

When Should You Use RCSI?

If you actually want my opinion on the subject: always. If you’re designing a new application, turn on RCSI from the get go and plan your hardware around living in a world of awesome. TempDB usage will be higher because that’s where SQL Server keeps all of the extra versions. Many DBAs will be worried about additional TempDB utilization, but there are ways to keep TempDB performing well.

The bigger question, of course, is why should I use RCSI?

Use RCSI to Eliminate Locking, Blocking, Deadlocks, Poor Application Performance, and General Shortness of Breath

RCSI may not cure pleurisy, but it’s going to future proof your application. Somewhere down the road, if you’re successful, you’ll have to deal with deadlocks. Turning on RCSI is going to eliminate that concern, or make it so minimal that you’ll be surprised when it finally happens.

A Snapshot of The Future: Looking Past RCSI

RCSI is probably all that most people think they going to need at the start of their architectural thinking. There will be circles and arrows and lines on a whiteboard and someone will say “We need to make sure that the DBAs don’t screw this up.” What they really mean is “Let’s talk to the data guys in a year about how we can make this greased pig go faster.”

Both of these versions can poop and bark.

During the early stages of an application’s life, a lot of activity consists of getting data into the database. Reporting isn’t a big concern because there isn’t a lot of data to report on and a few tricks can be used to make the database keep up with demands. Sooner or later, though, demand will outstrip supply and there will be problems. Someone might notice that long running reports aren’t as accurate as they should be. Numbers are close enough, but they aren’t adding up completely.

Even when you’re using RCSI, versions aren’t held for the duration of a transaction. The different isolation levels correspond to different phenomenon and those phenomenon, under a strict two-phase locking model, correspond to how long locks are held. When using one of the two MVCC implementations (RSCI or snapshots), the isolation levels and their phenomenon correspond to how long versions are kept around.

Using RCSI, or even READ COMMITTED, locks/versions are only held for a single statement. If a query has to read a table multiple times for a report, there’s a chance that there can be minor (or even major) changes to the underlying data during a single transaction. That’s right, even transactions can’t save you and your precious versions.

SNAPSHOT isolation makes it possible to create versions for the duration of a transaction – every time a query reads a row, it’s going to get the same copy of that row, no matter if it reads it after 5 seconds, 5 minutes, or 5 hours. There could be multiple updates going on in the background but the report will still see the same version of the row.

Getting Rid of Deadlocks in Practice

There are manual ways to accomplish eliminate deadlocks, but they require significant effort to design and implement. In many cases deadlocks can be eliminated by implementing either READ COMMITTED SNAPSHOT ISOLATION or SNAPSHOT isolation. Making the choice early in an application’s development, preferably during architectural decisions, can make this change easy, painless, and can be designed into the application from the start, making deadlocks a thing of the past.

Jeremiah Peschka

Jeremiah Peschka has worked as a database and emerging technology expert at Quest Software where he researched new trends and technologies in the world of data storage. Over the course of his career he’s worked with companies across many industries as a system administrator, developer, and DBA. He’s been involved with all aspects of application development and deployment. He likes cheesecake, coffee, and ice cream.

More Posts - Website

Follow Me:
TwitterFacebook

Which Sessions Will YOU Send to the SQL PASS Summit?

It’s votin’ time, folks. SQL PASS 2011 community sessions have been selected by the Program Committee, but there are still five slots up for grabs. Those five sessions are up to you, the community.

My Potential Session – “No More Bad Dates: Best Practices for Working With Dates and Times”

Vote for me and save this kitten.

Your votes could send me to speak at SQL PASS!

My “No More Bad Dates” session is up for community choice. Here’s the abstract for my session:

Dates and times seem simple at first. Kendra Little will show you there’s more to it than you think. She’ll give you five best practices that will help you select the right temporal data type, avoid common issues, and use the most effective techniques to aggregate data. She’ll also explain painful problems with query performance and how to avoid them. Choose wisely: the correct types and high performing data access logic will scale well and save development and administrative time.

Why I’d Like to Present This Session

This presentation surprises people. Dates and times are tricky, and they’re significantly evolving. We got some seriously big improvements in SQL 2008 and more cool changes are coming in SQL Server Denali.

I would love the opportunity to share these changes with the community.

How to Vote for SQL PASS Community Choice Sessions

Follow this link to the PASS Summit 2011 site. Log in with your existing account or create a new one. It should redirect you afterward to the voting page.

Then: vote!

Kendra Little

Kendra specializes in high availability and performance tuning. She is a Microsoft Certified Master in SQL Server-- the highest technical SQL Server Certification available. Kendra loves databases and software development more than long walks on the beach. Those cartoons in her blog posts? She draws 'em all. Read more and contact Kendra.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle PlusYouTube