10.07.2015 Views

The Definitive Guide to SQL Server Performance Optimization

The Definitive Guide to SQL Server Performance Optimization

The Definitive Guide to SQL Server Performance Optimization

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 1<strong>SQL</strong> <strong>Server</strong> uses caches <strong>to</strong> avoid not only physical reads but also time-consuming queryoptimization. Whenever <strong>SQL</strong> <strong>Server</strong> creates a query execution plan, it caches that plan for futureuse. Any subsequent uses of the exact same query won’t require a run through the queryoptimizer; instead, <strong>SQL</strong> <strong>Server</strong> will use the cached execution plan. <strong>SQL</strong> <strong>Server</strong>’s caches caninclude:• S<strong>to</strong>red procedures• Prepared statements• Ad-hoc queries• Replication procedures• Triggers• Views• Defaults• User tables• System tables• Checks• RulesEach of these objects can be s<strong>to</strong>red in <strong>SQL</strong> <strong>Server</strong>’s caches for improved performance.Understanding Hardware <strong>Performance</strong> ComponentsIn the end, all performance comes down <strong>to</strong> hardware. Although database administra<strong>to</strong>rs oftenfind themselves tweaking queries for better execution times, they do so only because it’s easierthan upgrading their server hardware. In fact, most of the performance tuning that you do as adatabase developer or administra<strong>to</strong>r will be <strong>to</strong> make your applications run faster on the hardwarethat you have. That doesn’t mean your applications or queries are poorly written; it simply meansthat you have <strong>to</strong> cut performance corners <strong>to</strong> make them run better on your hardware.Because all performance problems eventually come down <strong>to</strong> hardware, you need <strong>to</strong> take the time<strong>to</strong> understand how <strong>SQL</strong> <strong>Server</strong> interacts with the hardware on which it runs. Doing so will helpyou select better hardware for new <strong>SQL</strong> <strong>Server</strong> computers and help you better utilize thehardware on existing <strong>SQL</strong> <strong>Server</strong> computers. From a performance point of view, there are fourbasic hardware components: disks, networks, processors, and memory.Disk I/OAs I’ve already mentioned, disk throughput is often the bottleneck on <strong>SQL</strong> <strong>Server</strong> computers.Even if you’re running 8GB of RAM on a server, your databases can easily consume onehundred times that much space, meaning <strong>SQL</strong> <strong>Server</strong> is doomed <strong>to</strong> constant disk access. <strong>The</strong>reare, however, some tricks <strong>to</strong> improving disk I/O. I’ll show you how <strong>to</strong> identify and solve disk I/O problems in Chapter 3. Plus, in Chapter 6, I’ll explainhow you can scale out <strong>SQL</strong> <strong>Server</strong> <strong>to</strong> help solve disk I/O problems.Imagine, for example, that you need <strong>to</strong> produce a handwritten copy of a 1000-page book. Youcan either use one helper so that the two of you will have <strong>to</strong> each copy 500 pages, or you can usenine helpers so that you’ll each be responsible for only 100 pages. Because you can each copy afixed number of pages in any given period of time, the more hands you have helping you, the9

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!