Category Archives: SQL Server

SQL Server

SQL Server 2012 Certification Changes Video

In 2000, we worked on our MCSE and MCDBA certifications. In 2005, Microsoft changed things up with the MCITP and MCM programs. Things are about to change again – we’ve got the new MCSA, MCSE, and MCSM certifications. Join Kendra Little to learn more in this 30-minute webcast:

Learn More About Changes in Microsoft Certifications

Links from the webcast, and answers to some Q&A:

One insightful viewer asked about the differences between the two MCSE exams for Data Platform. They are titled “Developing Microsoft SQL Server 2012 Databases” and “Designing Solutions for SQL Server 2012.” I recommended checking out the skills measured for the exams (here and here). I re-reviewed these after the webcast and the “Developing” exam really isn’t about what we would typically think of as developer tasks– it includes things like index maintenance, automation of backups and jobs, and interpreting perfmon data as well as what we’d typically think of as developer tasks. Similarly, the “Designing” test also contains a mix of topics between what we have treated as two disciplines in the past.

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

Maintenance Plans and Roombas Suck – in a Good Way

Every now and then, I hear an experienced DBA say, “SQL Server maintenance plans for backups, indexes, and statistics?  What, are you kidding me?  Nobody uses maintenance plans because they suck.”

They say maintenance plans are so inflexible because they insist on defragging or rebuilding every index, every time, regardless of how little the table has changed.  Or maybe they complain about problems with scheduling, or how they saw somebody use a DBCC SHRINKDB maintenance plan once.

Well, I use maintenance plans all the time.

I even suggest ‘em to my clients.

In a perfect world, every DBA would have an unlimited amount of time to get the absolute best solution to every problem.  We’d spend endless time tuning T-SQL, perfecting plans, and daddying databases.  We’d drive home from work in our Porsche 911s to our mansion on the hill.

Back here in the real world, we have a limited amount of time to work each day.  We need to implement solutions that anybody can troubleshoot and maintain with a bare minimum of knowledge.  Sure, you might be the only DBA in the shop today, but wouldn’t it be nice to get a junior person hired, and then immediately be able to pass work off to ‘em?  I’ve seen shops where the lead DBA is still personally managing their homegrown maintenance scripts – the DBA doesn’t trust anyone else to touch this convoluted spaghetti code.

In the real world, we usually have two, or sometimes three, problems:

  1. The servers need to be maintained
  2. We need to save DBA time
  3. We need to save server time

Everybody has problem #1, but often problem #3 is overrated.  With careful use of maintenance plans, we can solve problems #1 and #2 easily.  Could the maintenance be done faster with custom scripts?  Yep – but when those scripts fail – and they will fail – we’ll make problem #2 worse, not better.

Maintenance plans aren’t perfect, but they require less troubleshooting time than your homemade scripts.  I know, you think your scripts are perfectly bulletproof and would never possibly have a bug, but time after time, I do SQL Server health checks and find some amazing problems.  Some highlights have included:

  • A t-log backup script that failed every night at 11pm without sending a warning
  • A 1mb database with 100GB of transaction logs because people thought it was in simple mode and their script skipped it by name
  • Databases that had never been backed up because the script used the wrong variable name for the database
  • DBCC jobs that completed successfully in under a second and nobody noticed.  They were using sp_msforeachdb, which is notoriously unreliable.

Maintenance plans have a killer advantage over custom maintenance scripts because they don’t have your bugs.  Let’s face it: we’re just not that good at writing code.  If we were, we’d be developers, not DBAs.  They do have bugs – but the bugs tend to be in bad implementation, like doing SHRINKDB, and those same problems pop up in custom maintenance scripts too.  If you’re smart enough to write a maintenance script, then you’re smart enough to use maintenance plans correctly.  (And conversely, if you’re not smart enough to use maintenance plans correctly, maybe you should ease up on those scripts, eh?)

I, for one, welcome our new fresh-smelling overlords

Maintenance plans are like my iRobot.  Their Scooba is a floor-cleaning robot that sprays cleaning solution on my wood floors, scrubs it (a little), and vacuums the liquid and dirt up.  It doesn’t do a great job – in fact, it does a pretty crappy job, leaving a damp trail of cleaning solution behind.  At first this bothered me, and I searched the web looking for ways to get it to do a perfect job and leave a dry floor behind.  No dice – everybody complains about the dampness.

Thing is, J-Lo (that’s my name for her, because she’s On the Floor) does a better job of floor maintenance than I can do in my spare time.  Once a week, I fill up J-Lo’s tank with cleaning solution, put in her battery, and turn her on.  I watch her do her thing while I write blog posts (and she’s doing it right now – I know you want to watch, but this is a private show.)  The cleaning solution evaporates, and I’m left with a cleaner apartment than I’d have had otherwise.

If you insist on using crafty scripts to do your database maintenance, use Ola Hallengren’s free scripts.  They’re powerful and he even updates ‘em frequently – just this week, he added support for the new preferred-replica-backup DMVs for SQL Server 2012′s AlwaysOn Availability Groups.

That’s the curse and blessing of scripts – even good scripts like Ola’s require maintenance because new versions come out from time to time.  If you don’t have the time to maintain and debug scripts, use maintenance plans.  Take all that time you save, and keep reading blogs to fix problems that actually bother your end users.

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

DBA Darwin Awards: T-SQL Edition Webcast

Working in the SQL Server emergency room, I see a lot of self-inflicted performance wounds. That query looks good, and it looks like it’s using an index – but why does it take so long? The query runs great half the time, but the rest of the time performance is cut off at the knees, and the only fix is to restart the server. Learn the top 3 T-SQL traumas I see in my practice:

Liked this webcast? I’m doing a new 3-hour online training session on how to make SQL queries run faster.  You’ll learn:

  • How to find the worst queries on the server in 60 seconds
  • What statistics are and how to tell if they’re causing problems
  • How to think like the engine and build your own execution plan
  • Why filters are cheap and sorts are expensive
  • When you should throw indexes at the problem, and exactly when to stop
  • Why temp tables might be the fastest way to fix many problems
  • How to identify parameter sniffing problems and fix ‘em for good

Check it out and register today.

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

Hash Partitioning, SQL Server, and Scaling Writes

At first glance, SQL Server’s partitioning seems like it should be an easy way to solve problems inserting data into busy tables. If the writes are spread across many partitions it only makes sense that we can avoid write hot spots in SQL Server, right? The truth is much more complicated than it appears.

Asking the Right Questions

A reader commented on Kendra’s post How To Decide if You Should Use Table Partitioning asking “what are the plusses and minuses to using Hash partitioning on OLTP tables with large numbers of inserts on a daily basis?” The pros are pretty easy to see – SQL Server will spread the writes out across many partitions which, in turn, allows you to spread the writes out within multiple file groups in each partition. It seems obvious that this will solve problems with allocation map contention under write heavy workloads.

If the only problem that you’re trying to solve is eliminating write contention in a filegroup, you can improve SQL Server performance by adding multiple files to that file group, then rebuild indexes. After the index rebuild, data will be distributed evenly between the different files. Since each file has its own set of allocation map pages, you’ll see less contention across the different allocation map pages. The upside of this approach is that you don’t have to make any changes apart from adding extra data files to the filegroup. SQL Server’s proportional fill algorithm should take care of the rest.

Of course things are never as simple as that, right?

Even if you manage to add enough data files to handle our data file write throughput, the transaction log will still be the biggest bottleneck. You can push SQL Server write performance a long way, especially if you follow the advice in these SQLBits videos from Thomas Kejser, but eventually you will hit the limits of a single transaction log. If the log can’t keep up, the number of data files won’t matter: you won’t be able to write any faster than you can write to your transaction log.

This is why it’s so important to ask “What’s the problem you’re trying to solve?”

Write Throughput & Multi-Tenancy

The original poster asked about the pros and cons of using hash partitioning in an OLTP system to deal with a large number of inserts. Hash partitioning uses some kind of hash function to evenly distribute data between a finite number of buckets. While a hash function will solve the problem of distributing data, hashing won’t make it possible distribute writes to multiple log files – SQL Server only allows for one log file per database. Sure, you can add more disks behind the log file to make it respond faster but there is only so much you can do. Limitations are imposed on storage throughput simply because you can only fit so many HBAs in a server chassis before you run out of PCI slots and you can only buy so much Infiniband before you run out of budget.

When the transaction log becomes the limiting factor in a database’s write performance, it’s time to split the database into multiple databases. This is where things get difficult: where is the decision made to partition data across databases?

In multi-tenant systems it’s relatively easy to partition data across databases – each client’s data moves to its own database and any global metadata can either live in a central database or can be replicated to each client database. Partitioning the data by client ID is the natural way to split out the data. Most, if not all, queries will be limited to a single client and the application can handle any cross client joins that administrative users need to run.

The upside of this approach is that you can spread your data across multiple servers and handle performance problems on each server as needed. The downside is that using a hash function with a fixed number of servers means that adding another server means repartitioning all of the data and shuffling it between servers. Needless to say, this can take a long time.

Write Throughput & Single Tenancy

Let’s pretend that you don’t have a lot of different clients. You have one big client and you’re streaming a lot of sensor readings from multiple sensors into a single database. Things become more difficult when data is being streamed into a single tenant application – say you’re streaming sensor data into a single application database. Sometimes it’s not so easy to partition this data. There are a few ways to handle the load and none of them are great.

One of the most obvious ways to handle massive write concurrency in a single tenant system is to find the a level of the application where writes can be partitioned – in this example write partitioning could happen at the sensor level, sensors could be grouped, or the hash might be found by converting the current time to seconds and reversing the digits to bring more randomness the hash function output. This will help spread the load across multiple servers but it won’t make any easier to query the data. You need to do something other than spread the data randomly across some random number of servers.

Writing Faster Without A Database

Assuming that our goal is to handle more write throughput, the easiest thing to do is remove the database from the equation altogether. After all, if we aren’t writing to a database then we can’t run into issues with log throughput or allocation map contention. We can’t actually get rid of the database, but we can remove it from directly causing performance problems.

The first thing to do is add several cache servers in front of our database server. Ideally you want to have multiple cache servers for redundancy. Since the cache servers are nothing more than boxes loaded full of memory it shouldn’t be expensive to find servers that fit the bill. Before any data is committed to the database it needs to be written into the cache. It might be difficult to modify application patterns to work with the cache, but it can be done. 37signals redesigned how they handled caching page elements in their Basecamp product do use tiers of cache. The same ideas can be applied to your application – write data at the most granular level possible in your cache and cascade calculations throughout your cache.

The next step is to add a queuing mechanism to handle writes into your database. After you write to the cache, throw your writes into a durable queue. RabbitMQ is an example of a queue that can be clustered, is highly available, and can be backed by a durable store. By adding a durable queue alongside the cache it is possible to scale reads (the cache) independently of writes (the queue) without having to worry as much about performance in the underlying database.

Processing writes is a matter of setting up additional processes to read data from the queue, process the instructions, and write data to the database. This could happen by pulling off batches of tens or hundreds or even thousands of instructions at a time, processing them, and then inserting them into the database in one transaction and hopefully improving performance by avoiding a lot of small inserts. You still have to handle the write load into the database and handling scalability issues with the transaction log so this strategy relies on being able to find a performance point where it is advantageous to medium to large size batches instead of many small transactions. At some point, you might even have to start partitioning your data across multiple servers underneath the caches and queues, but your application won’t need to be as aware of that data split taking place. Caching and queuing hide that implementation pain from the middle tiers.

The Answer

There’s no correct answer. Pushing writes into a partitioned table means having to deal with the pain points of SQL Server’s table partitioning. Splitting writes out among multiple databases or servers can make it difficult to query your data. Implementing caches and queues adds operational complexity and requires expertise that some teams may not have.

The more flexibility you require, the more difficult it becomes to handle additional writes. At some point it might even become necessary to find ways to move the write heavy portions of your application out of SQL Server and into another application that does a better job of handling distributed writes.

Always ask yourself what problem you’re trying to solve and make sure that you’re solving it in the best way. Bolting something like consistent hashing on top of SQL Server is going to be painful, at best. But there may be a different way to solve the problem that’s less painful, operationally simpler, or a little bit of both.

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

Why Is My Virtual SQL Server So Slow?

After we virtualize SQL Server, troubleshooting performance becomes a lot tougher.  There’s more moving parts like shared storage and VMware, and we DBAs don’t usually get access to those tools to find out what’s going on.  So what’s a DBA to do?

I'm slow because I keep staring at my feet, apparently.

Wednesday, I’m doing a free one-hour webcast talking about what makes virtual SQL Servers so slow. You’ll learn:

  • Why Page Life Expectancy is less reliable in virtualization
  • Why more cores means more problems
  • Why virtual storage is usually 10-100x slower than our physical boxes
  • What Perfmon counters to watch for VMware servers

This session is targeted at production database administrators with 1-5 years of experience, and it’s completely free.  It’s prerecorded, but I’ll be there live in the chat during the webcast.  I’m really tickled with how it turned out – I ended up going off-topic to talk about women’s restrooms, among other odd things.  Even when I’m webcasting alone, I manage to entertain myself.

Register now. For even more information, check out my upcoming virtual training.

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

How to Interview Storage Vendors

Buying SAN gear is hard work.  You have to compare vendors based on performance, capacity, reliability, ease of implementation, quality of support, and of course, price.  When I’m working with a client buying new storage, here’s the questions I have them ask each prospective storage vendor.

Q: If we buy SSD, SAS, and SATA drives, how does the tiering work?  Some vendors can automatically move data between fast and slow drives, while other vendors only allow this manually – if at all.  If the storage does all the work for you, find out what kind of reporting it offers – some tiering solutions will automatically use SSDs where possible, but you’ll want to know when it’s time to buy more drives for each tier.

Q: Is SSD used for caching or for storage? How much do you recommend?  There’s no wrong answer here, but listen to their recommendations.  This is often the fastest way to improve performance.  It’s going to be expensive, but that’s not part of the technical decision.

Q: Do you support active/active multipathing for both sending and receiving on a single LUN?  If you have just one 1TB volume, and you’ve got a handful of connections to the storage, can you use multiple connections simultaneously to get more throughput during read/write intensive operations?  Most vendors just don’t support this, so ask them to be as specific as possible – it’ll help you design the right connectivity for your storage.  No multipathing capabilities means your big databases may need 8Gb FC or 10Gb iSCSI connectivity, and they may need to be broken up across multiple files on multiple LUNs.

Q: Does the system include snapshots? Are they writable?  Do they integrate with SQL Server?  SAN snapshots are one of my favorite tricks to speed up multi-terabyte database backups.  We can take a snapshot of entire SAN volumes in a matter of seconds – but only if the vendor includes this support.  Some vendors include it, and some vendors charge an arm and a leg.

Q: Exactly how much can we grow before we have to make a major upgrade?  Storage gear is a lot like servers: if you need to get an incremental performance upgrade you may be able to throw in a few more drives, but if you need to double or quadruple your performance, you might get stuck replacing the whole thing.  Ask exactly how much cache, how many ports, and how many drives you can add before you have to make big changes.

Q: What are your best practices for Microsoft SQL Server?  Ask for their technical documentation on configurations.  They may not have an up-to-date version for SQL Server 2012, for example, but they should at least have a copy for 2005 or 2008.  Examine that documentation for things like RAID levels, multipathing, drive separation, and so forth, and take those guidelines into account as you spec out hardware.  If they don’t have guidelines for Microsoft SQL Server, ask for Oracle, but if they don’t have either of those, be aware that you’re going to be on your own for performance troubleshooting.

Q: How frequently have firmware upgrades come out in the last 6 months, and what’s the upgrade process like?  Insist on specifics from their technical documentation, not general sales and marketing info.  If they’re putting out firmware upgrades every few weeks, and if they recommend these upgrades in order to get support, and if you’re required to take all attached servers down in order to perform the upgrade, that’s a problem.  If, on the other hand, they recommend performing the upgrades online, administration will be much easier.  Insist on the specifics, though, because I’ve seen SAN vendors say, “Well, you could do the upgrade online…but we don’t recommend that.”

Q: Can I talk privately to a similarly-sized customer?  Ask for a nearby reference that you can have a private conversation with – without the storage vendor’s staff around.  Try to get someone technical from the reference company, not a C-level executive, because you want someone who’s working with this thing every day.  Ask about the company’s experience with performance, capacity, reliability, ease of implementation, and quality of support.  Do it in person, not over the phone or over email, because you’ll be more likely to get the off-the-record truth.  Ask them, “If you were going to do it all over again, would you buy this product – or if you were going to buy something else, what would it be?”

After you’ve compiled everyone’s answers together, you should be able to narrow down the field to a few strong contenders.  From there, ask each vendor to provide access to a system similar to the one you’d be purchasing.  If you’re spending enough money, either you can access the system remotely, or they’ll loan you a demo set of gear to install in your datacenter.  Asking the right questions ahead of time ensures that you’ll spend the least amount of time kicking the tires of gear that just won’t perform.

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

An Introduction to VLDBs Video

Big data’s grandpa is the Very Large DataBase (VLDB) and we’ve been doing VLDBs in SQL Server for years. Making the jump from managing 10-100GB databases to the terabyte level can be intimidating, but in this 30-minute session, Brent Ozar will share the lessons he learned along the way so you don’t have to get burned. He’ll cover the basics of why backups, restores, DBCCs, and query tuning are so different for VLDBs.

Like this?  Want to see more?  Check out our upcoming webcasts:

April 10 – Database Darwin Awards: T-SQL Developer Edition
Brent Ozar, Tech Triage Tuesday

Working in the SQL Server emergency room, I see a lot of self-inflicted performance wounds. That query looks good, and it looks like it’s using an index – but why does it take so long? The query runs great half the time, but the rest of the time performance is cut off at the knees, and the only fix is to restart the server. Learn the top 3 T-SQL traumas I see in consulting engagements, and find out whether they’re affecting your environment. Register now.

April 18 – Scaling SQL on Solid State: Hot & Crazy
Brent Ozar, South Florida SQL User Group (SFSSUG) (Remote)

SSD prices are coming down and adoption is going up. My clients have used them to solve all kinds of performance problems, and we’ve found some surprising results. In this session, I’ll explain the internals of these fast drives and show the pros and cons of the various connection methods (SATA, PCI Express, SAN). Then we’ll switch over to the SQL Server world to see how to tell when and where you need SSDs. You’ll even get real-world before-and-after metrics to help make the case to management. Register now.

April 24 – How to Test Availability Groups in SQL Server 2012
Kendra Little, Tech Triage Tuesday

Want a jump-start on testing the hottest scale-out feature in SQL Server 2012? Kendra Little will tell you why it’s critical that you configure your own lab, and what you need to get your test environment set up. She’ll also detail how to avoid some gotchas that could cost you hours of frustration. She’ll demonstrate the steps you need to enable the Availability Group feature in SQL Server 2012 and how to create and test your first Availability Group. This session is appropriate for DBAs with one or more years of experience with SQL Server. Register now.

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

How Fast Does Your SAN Need to Be for SQL Server?

Let’s oversimplify the bejeezus out of this complex problem.  Suspend your disbelief for a second and work with me:

We have a database server hosting just one 100GB table.  Sure, in reality, we’ve got lots of databases and lots of tables, but we’re going to keep this simple.  We’ve got a simple sales table that stores a row for each sale we’ve ever had.  We don’t have any indexes: this is just 100GB of raw data in our clustered index.

Our database server has 32GB of memory.  Some of that is going to be used by the operating system, drivers, the database software, and that bozo who keeps remoting into the server and playing Angry Birds, but again, we’re going to keep this really simple and pretend that all 32GB of memory is actually used for caching data.  We don’t have enough to cache the entire 100GB table, though.

A user runs a query that needs to scan the entire table.  They want sales numbers grouped by year, by region.  In decision support systems, users run all kinds of wacko queries, and we can’t build indexes to support all of them, but even if we could, we’re keeping this scenario simple and assuming that we have 100GB of raw data and no indexes whatsoever.  To satisfy this query, we have to read all 100GB of data.

Before our query can finish, we have to read 68GB of data from disk.  That’s our 100GB table minus 32GB of it that happens to be cached in memory.  I’m assuming that we’ve got a warm cache here with some 32GB of the data in memory, although I don’t know which 32GB, and it doesn’t really matter.  We can’t fit 100GB of data in a 32GB bag.

The user wants the query to finish in 10 seconds or less – preferably much less.  Presto: now we know how fast storage needs to be.  We need to be able to read 68GB of data in less than 10 seconds.  We can test our storage to see whether it meets that number using my recent post on how to check your SAN speed with CrystalDiskMark.

The Magic SAN Speed Formula

The final formula is beautifully simple: how much time do we have, and how much data do we need to read?  The business is responsible for telling us that first number, but the second number is a heck of a lot harder to gather.  We have to put ourselves into the above scenario and boil things down to the simplest possible illustration of the worst case scenario.

How much memory is available for caching data?  Use these simple DMV queries to find out how much memory each database is using, and even better, how much each object in each database is using.  You might be surprised at how little memory is available for caching because your server needs so much memory for other tasks like keeping the OS’s lights on and sorting your query data.  This is why I’m so emphatic that you should never remote desktop into a SQL Server – by launching programs there, you’re consuming very valuable memory.

How big is the biggest table we need to query?  Use this DMV query to calculate the size of all the tables in your database – both with and without indexes.  The results help explain why more indexes aren’t necessarily better: they’re all competing for the same memory.  When I’ve got two overlapping indexes that are both getting used, I’m cutting my cache capabilities.

Can we use an index to satisfy the query?  Sometimes the answer to faster storage is writing better queries that can leverage indexes rather than doing table scans.  This is why it’s important to understand sargability and implicit conversions.

How much of this data can we guarantee will be in cache?  Think worst case scenario: other queries may be running, or other databases on the system might be more active and taking over the cache.  The more memory I put in the server, and the more I isolate performance-critical databases away from the rest, the more I can guarantee fast queries by caching data.

Microsoft’s Reference Architecture Specs for SAN Speeds

Microsoft’s Fast Track Data Warehouse systems are purpose-built database servers that ship with everything you need to get fast performance.  They’re available from hardware partners like Dell, HP, and IBM, and Microsoft works with ‘em to make sure you’ll get the speed you need.

The Fast Track reference architectures assume that we can’t satisfy queries via indexes, and they don’t even try to cache the data in memory.  They just flat out assume queries will be performed using table scans, so they require very high speed storage performance:

“…this system architecture is called the Core-Balanced Architecture. This balanced approach begins with what is called the CPU core consumption rate, which is the input capacity that each CPU core can handle as data is fed to it.”

This is a really different approach, and it starts to explain SQL Server 2012′s licensing of around $7k per core for Enterprise Edition.  If you’re going to pay big money for 40 cores of that licensing, wouldn’t it make sense to ensure that those CPUs can actually do work?  By specifying a minimum IO throughput per core, Microsoft guarantees that the server could actually get busy.  Otherwise, we’re harnessing expensive thoroughbred racehorses to a crappy chariot.  The Fast Track Configuration Guide even goes so far as showing you how to calculate a Maximum Consumption Rate and a Benchmark Consumption Rate for your system before going live. (I love Microsoft.)

In a typical customer environment I worked with recently, their current IO subsystem was able to deliver 300-400MB/sec.  By using the questions above and looking at Microsoft’s Fast Track reference architectures, we calculated that they needed closer to 4,000MB/sec in order to satisfy their end user requirements for query times.  Put another way, if we didn’t change any of the other variables, we needed to make the storage ten times faster.   Obviously, making that kind of improvement ain’t easy or cheap – and suddenly we got buy-in from management to change some of the other variables.

When you see the whole picture – licensing, storage throughput, query design, and end user requirements – it’s much easier to find the right way to get faster performance.  Sometimes it’s insanely fast IO throughput like Microsoft’s Fast Track solution, and sometimes it’s rewriting queries to improve index utilization.  Showing the real cost of storage throughput helps justify why query writers need to step back and rewrite troublesome parts of the app.

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

How Fast is Your SAN? (Or How Slow?)

A few years ago, Erika and I went to the VW dealership to trade in her old Jetta and get a new one.  The choice of a Jetta was already a foregone conclusion – she loved VWs at the time – and it was just a matter of picking out colors and options.

Bringing the Jetta Home

We took a test drive of the base model, and then the sales guy asked, “Do you wanna also test drive the 1.8L Turbo version?”

Me (immediately): “No.”

Erika: “Sure, why not?”

Me: “You were just saying how this one is so much peppier than yours.  You – and by you I mean we – don’t need a turbo.”

Erika: “Come on, let’s try it.”

As soon as she accelerated onto a highway on-ramp, felt the power surge, and heard the turbo whistle, that was the end of that.  Suddenly, I felt like a SAN administrator and Erika was the DBA.  “No no no,” I was saying, “You don’t need that.  You’re never going to go that fast, and I know because you yell at me when I take highway on-ramps that fast.  Let’s not spend the extra money if we’re not getting extra capacity.  Besides, let’s bring it back to numbers – let’s measure how fast the base version is to 60mph, and then measure the turbo version.”

She couldn’t hear me because I was in the back seat and she was negotiating price with the sales guy.  The seat-of-the-pants feeling of speed was enough for her, and often it’s good enough for us DBAs too.

Measuring Your SAN the Easy Way

I’ve written about how to test your SAN’s performance with SQLIO, but I’ll be honest with you: that’s the hard way.  It takes knowledge and time, and you only have one of those.  (I’ll be charitable and not tell you which one.)

Instead, let’s get seat-of-the-pants numbers for your storage.  Go download the portable edition of CrystalDiskMark (NOT CrystalDiskInfo) and put it on a network share.  Run it on an idle server (not your live SQL Server, because it’ll slow things down while it runs.)  It’ll look like this:

CrystalDiskMark

Across the top, there’s three dropdowns:

  • 5 – the number of test passes you want to run.  If you want a fast seat-of-the-pants guess, do 1, but keep in mind it can be wildly variant between passes if something else happens to be going on in the SAN.
  • 4000MB – the test file size.  I like using 4000MB to reduce the chances that I’m just hitting cache and getting artificially fast numbers.  Smaller test file sizes may look fast but don’t really reflect how a large database will work.
  • E: – the drive letter to test.  Keep an eye on the free space there – you don’t want to create a test file that can run your server out of drive space.

After making your choices, click the All button.  While it runs, here’s an explanation of each row’s results:

  • Seq – long, sequential operations. For SQL Server, this is somewhat akin to doing backups or doing table scans of perfectly defragmented data, like a data warehouse.
  • 512K – random large operations one at a time.  This doesn’t really match up to how SQL Server works.
  • 4K – random tiny operations one at a time.  This is somewhat akin to a lightly loaded OLTP server.
  • 4K QD32 – random tiny operations, but many done at a time.  This is somewhat akin to an active OLTP server.

The more astute readers (and by that I mean you, you good-looking charmer) will notice that 4K operations don’t really measure SQL Server’s IO.  SQL Server stores stuff on disk in 8K pages, and zooming out a little, groups of 8 8KB pages (64K extents).  We’re not looking to get an exact representation of SQL Server’s IO patterns here – we’re just trying to get a fast, one-button-click-easy measurement of how storage performs.  Usually I find that during the first round of storage tests, it’s not performing well period – and it doesn’t make sense to bring SQL Server into the game just yet.

Interpreting CrystalDiskMark Results

For magnetic hard drives (individually or in RAID arrays), sequential operations (the top column) are often 10x-100x the rest of the results.  This metric is often limited by how the computer is connected to the storage, and you can get those numbers from the bandwidth rates in Kendra Little’s “How Big Is Your Pipe?” bandwidth reference poster.  Keep in mind that the MB/sec numbers on the poster are theoretical limits, and in practice, we’ve got 5%-20% overhead involved.

For solid state drives, the difference between sequential and random operations isn’t always as dramatic, but it can still be 2-3x.  If there’s no difference, then I’d look even closer at the connectivity method – the SSDs are probably outperforming the connection method (like 3Gb SATA, 1Gb iSCSI, or 2/4Gb FC.)

So what’s a good or bad number?  If your server boots from a mirrored pair of local drives, and stores its SQL Server data somewhere else (like on a larger array or on a SAN), then test the local mirrored pair too.  Compare the numbers for where you’re storing the valuable, high-performance data to where you’re storing the OS, and you might be surprised.  Often I find that the OS’s drives perform even better because we just haven’t configured and tuned our storage.

Keep these original CrystalDiskMark screenshots in a shared folder for the group to access, and then challenge everyone involved to do better.  Simple tuning techniques like tweaking the read/write bias on the RAID controller’s cache, right-sizing the NTFS allocation units, and working with different stripe sizes can usually yield double the storage performance without spending a dime.

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

Let’s Talk About Joins

If you want to learn more about the different join algorithms, consult Wikipedia for an introduction to the basic material and links to additional information:

Additional information is also found in the paper Implementation Techniques for Main Memory Databases.

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