Click here to monitor SSC
Robert Sheldon

14 SQL Server Indexing Questions You Were Too Shy To Ask

One of the first things one needs to understand well about SQL Server is indexes, but somehow many of the basic questions don't often get asked or answered much on forums. Rob Sheldon answers some of these shy-making questions about SQL Server Indexes and indexing: the ones we somehow feel silly asking in public, and think twice about doing so. Read more...

Joshua Feierman

Applying The Scientific Method to SQL Server Performance Tuning

Database administrators tend to rely more on science than intuition, and may therefore seem exasperatingly cautious to other IT people. A relational database is a complex machine, however, that is asked to deal with intricate problems. When things go wrong, it usually takes knowledge, deduction and a systematic approach to track down the root core of problems and to determine the best fix. Read more...

Fabiano Amorim

Fixing Cache Bloat Problems With Guide Plans and Forced Parameterization

Imagine it. You've been asked to fix a dire performance problem with a SQL Server database. You find a severe case of 'Cache Bloat' due to ad-hoc queries, but you can't fix the code itself. What should you do? Specify forced parameterization? Perhaps a better idea would be to use guide plans. Read more...

Gail Shaw

SQL Server Deadlocks by Example

When a SQL Server instance deadlocks, it can be anything from minor irritation to something far more severe. In this article, Gail Shaw looks at how you can identify common types of deadlock, the difference between a deadlock and severe blocking, and how to avoid and fix the most common deadlock types. Read more...

Alex Kuznetsov

Lessons Learned from Six Years of Agile Database Development

Alex Kuznetsov describes the agile principles, techniques and tools that allowed his development team to make frequent database refactoring a reality, without disrupting users. He explains how this allowed his team to apply an iterative, evolutionary approach to the design and development of their databases, as well as applications. Read more...

Nigel Rivett

The ETL from Hell - Diagnosing Batch System Performance Issues

Too often, the batch systems that underlie a lot of database processing just grow without conscious design. When runs start to extend beyond their allotted time, and tuning no longer solves the problem, it is often discovered that batches are run in series, with draconian error handling. It is time to impose some rational design, and Nigel is a seasoned healer of batch processes. Read more...

Seth Delconte

Introduction to SQL Server Filtered Indexes

SQL Server filtered indexes can save space and improve performance if they are used properly. Under what circumstances can they be used? When are they most effective, and what sort of performance gain or space-saving is likely? How does a filtered index affect the choice of execution plan? Seth explores these questions with practical experiments Read more...

Erin Stellato

Managing SQL Server Statistics

Accurate statistics about the data held in tables are used to provide the best execution strategy for SQL queries. but if the statistics don't accurately reflect the current contents of the table you'll get a poorly-performing query. How do you find out if statistics are correct, and what can you do if the automatic update of statistics isn't right for the way a table is used? Read more...

Fabiano Amorim

Join Reordering and Bushy Plans

Normally, the query Optimiser won't consider 'bushy' plans, where both operands to a join operator could be intermediate results from other joins. This means that it won't produce good query plans for some types of query. Hints, by themselves won't do it. More powerful magic is required. Read more...

Eugene Philipov

Comparing multiple rows insert vs single row insert with three data load methods

The performance of 'extract, transform, load' (ETL) processes for large quantities of data can always be improved by objective testing and experiment with alternative techniques. The cause of poor performance can sometimes be surprising. Read more...

Grant Fritchey

SQL Server Statistics Questions We Were Too Shy to Ask

If you need to optimise SQL Server performance, it pays to understand SQL Server Statistics. Grant Fritchey answers some frequently-asked questions about SQL Server Statistics: the ones we somehow feel silly asking in public, and think twice about doing so. Read more...

Louis Davidson and Tim Ford

Tune Your Indexing Strategy with SQL Server DMVs

SQL Server Indexes need to be effective. It is wrong to have too few or too many. The ones you create must ensure that the workload reads the data quickly with a minimum of I/O. As well as a sound knowledge of the way that relational databases work, it helps to be familiar with the Dynamic Management Objects that are there to assist with your indexing strategy. Read more...

Grant Fritchey

The Seven Sins against TSQL Performance

There are seven common antipatterns in TSQL coding that make code perform badly, and three good habits which will generally ensure that your code runs fast. If you learn nothing else from this list of great advice from Grant, just keep in mind that you should 'write for the optimizer'. Read more...

Fabiano Amorim

SQL Server Prefetch and Query Performance

Prefetching can make a surprising difference to SQL Server query execution times where there is a high incidence of waiting for disk i/o operations, but the benefits come at a cost. Mostly, the Query Optimizer gets it right, but occasionally there are queries that would benefit from tuning. Read more...

Jonathan Kehayias

A Performance Troubleshooting Methodology for SQL Server

When healing a sick SQL Server, you must forget the idea that there could ever be a simple correspondence between symptom and disease: The art of troubleshooting is much more the art of discovering, and assembling, the various pieces of the puzzle so that you have a complete understanding of what is going on inside of a server Read more...

Mark and Stephanie

Regular Rapid Releases: An Agile Tale

While developing their new SQL Source Control tool, a team at Red Gate learned a lot about Agile development, as well as the benefits (and challenges) of rapid, regular Early Access releases. Stephanie Herr (project manager for SQL Source Control) and Mark Wightman (head of development at Red Gate Software) tell us more. Read more...

Joe Celko

Improving Comparison Operators and Window Functions

It is dangerous to assume that your data is sound. SQL already has intrinsic ways to cope with missing, or unknown data in its comparison predicate operators, or Theta operators. Can SQL be more effective in the way it deals with data quality? Joe Celko describes how the SQL Standard could soon evolve to deal with data in ways that allow aggregation and windowing in cases where the data quality is less than perfect Read more...

Feodor Georgiev

The default trace in SQL Server - the power of performance and security auditing

Since the introduction of SQL Server 2005, there is a simple lightweight trace that is left running by default on every SQL Server. This provides some very valuable information for the DBA about the running server, but it isn't well-documented. Feodor reveals many of the secrets of this facility and shows how to get reports from it. Read more...

Fabiano Amorim

Lipoaspiration in your SQL Server Database

Once, when disk space was at a premium, DBAs fought hard to keep the size of their database down. Now there seems less motivation to 'fight the flab' of a database. Fabiano Amorim was watching television recently when the subject matter, cosmetic surgery, gave him the theme and inspiration for this guide to keeping your database fit and trim. Read more...

Robert Sheldon

The EXCEPT and INTERSECT Operators in SQL Server

The UNION, EXCEPT and INTERSECT operators of SQL enable you to combine more than one SELECT statement to form a single result set. The UNION operator returns all rows. The INTERSECT operator returns all rows that are in both result sets. The EXCEPT operator returns the rows that are only in the first result set but not in the second. Simple? Rob Sheldon explains all, with plenty of examples Read more...

Feodor Georgiev

Collecting Performance Data into a SQL Server Table

Occasionally, when tracking down a performance problem, you have to have information over time on the values of particular sets of performance counters. To track down the more insidious or sporadic problem, it is best to have the data in a SQL Server table, so you can query it. Feodor Georgiev explains the command-line way of doing this. Read more...

Greg Larsen

Which of Your Stored Procedures are Using the Most Resources?

Dynamic Management Views and Functions aren't always easy to understand. However, they are the easiest way of finding out which of your stored procedures are using up the most resources. Greg takes the time to explain how and why these DMVs and DMFs get their information. Suddenly, it all gets clearer. Read more...

Benjamin Nevarez

Index Selection and the Query Optimizer

While we all know that the Query Optimizer uses Indexes to produce better execution plans, we don't all know exactly which indexes will give the best results. Benjamin Nevarez has done the research, and in this sample from his upcoming book, "Inside the SQL Server Query Optimizer", he helps us to understand how the Query Optimizer selects indexes to improve execution plans. Read more...

Holger Schmeling

SQL Server Statistics: Problems and Solutions

SQL Server Statistics assist the query optimiser to calculate the best way of running the query. Holger describes every common way that things can go wrong with statistics, and how to put matters right. Read more...

Holger Schmeling

Queries, Damned Queries and Statistics

In a perfect world, we should just be able to write queries and leave the RDBMS to decide the perfect strategy to get the data. Until then we have to understand the Query Optimizer and the way it uses distribution statistics. Read more...

Kathi Kellenberger

SSN Matching Speed Phreakery

On Ask.SQLServerCentral.com, a group of people interested in experimenting with heavily optimised SQL techniques try them out on a problem, using reasonbly large amounts of data. They aren't so interested in explaining the techniques, so Kathi continues on her mission to explain the lessons learned and the tips that can be derived. Read more...

Kathi Kellenberger

Set-based Speed Phreakery: The FIFO Stock Inventory SQL Problem

The SQL Speed Freak Challenge is a no-holds-barred competition to find the fastest way in SQL Server to perform a real-life database task. It is the programming equivalent of drag racing, but without the commentary box. Kathi has stepped in to explain what happened with the second challenge and why some SQL ran faster than others. Read more...

Rod Colledge

Reliable Storage Systems for SQL Server

By validating the IO path before commissioning the production database system, and performing ongoing validation through page checksums and DBCC checks, you can hopefully avoid data corruption altogether, or at least nip it in the bud. If corruption occurs, then you have to take the right decisions fast to deal with it. Rod Colledge explains how a pessimistic mindset can be an advantage Read more...

Rod Colledge

High Performance Storage Systems for SQL Server

Rod Colledge turns his pessimistic mindset to storage systems, and describes the best way to configure the storage systems of SQL Servers for both performance and reliability. Even Rod gets a glint in his eye when he then goes on to describe the dazzling speed of solid-state storage, though he is quick to identify the risks. Read more...

Jonathan Lewis

Designing Efficient SQL: A Visual Approach

Sometimes, it is a great idea to push away the keyboard when tackling the problems of an ill-performing, complex, query, and take up pencil and paper instead. By drawing a diagram to show of all the tables involved, the joins, the volume of data involved, and the indexes, you'll see more easily the relative efficiency of the possible paths that your query could take through the tables. Read more...

Kathi Kellenberger

Writing Efficient SQL: Set-Based Speed Phreakery

Phil Factor's SQL Speed Phreak challenge is an event where coders battle to produce the fastest code to solve a common reporting problem on large data sets. It isn't that easy on the spectators, since the programmers don't score extra points for commenting their code. Mercifully, Kathi is on hand to explain some of the TSQL coding secrets that go to producing blistering performance. Read more...

Josef Richberg

Simple Query tuning with STATISTICS IO and Execution plans

A great deal can be gleaned from the use of the STATISTICS IO and the execution plan, when you are checking that a query is performing properly. Josef Richberg, the current holder of the 'Exceptional DBA' award, explains how an apparently draconian IT policy turns out to be a useful ways of ensuring that Stored Procedures are carefully checked for performance before they are released Read more...

Grant Fritchey

Controlling Execution Plans with Hints

The Query Optimizer gets it right most of the time, but occasionally it chooses a plan that isn't the best possible. You can give the Query Optimiser a better idea by using Table, Join and Query hints. These come with a risk: Any choices you force on the Optimizer by using hints can turn out to be entirely wrong as the database changes with the addition of data over time. Grant Fritchey, in a chapter from his highly acclaimed book, explains further. Read more...

Laerte Junior

Reducing I/O with the 'Missing Indexes' DMVs

Laerte recently experienced an I/O nightmare, which, as a happy accident, gave him an opportunity to test out the ‘Missing Indexes’ DMVs and see if they were up to scratch. He solved his problems, ran a few tests to get a feel for how well the DMVs performed, and was very impressed. So much so, that he is sharing his findings with us. Read more...

Brad McGehee

Mastering SQL Server Profiler - eBook Download

Download Brad McGehee's "from the ground up" guide to SQL Server's most powerful performance diagnostic tool. Read more...

Grant Fritchey

SQL Server Execution Plans - eBook Download

Why is my query running slow? Why isn't my index getting used? In order to answer these questions, you have to ask the same return question in each case: have you looked at the execution plan? Grant Fritchey provides the only dedicated and detailed guide to this essential topic. Download the eBook. Read more...

Gail Shaw

Finding the causes of poor performance in SQL Server, Part 2

In the first part of this series of articles, Gail showed how to find the procedures that contributed most to performance problems. In this final part, she shows how to use query statistics to pinpoint the queries that are causing the biggest problems, and then use the query execution plans to find out which operations are the root cause. With this information one can select and modify the indexes that can optimize the plans and therefore performance of the query. Read more...

Gail Shaw

Finding the Causes of Poor Performance in SQL Server, Part 1

To tackle performance problems with applications, you first find the queries that constitute a typical workload, using SQL Profiler: Then, from the trace, you find the queries or stored procedures that are having the most impact. After that, it is down to examining the execution plans and query statistics to identify queries that need tuning and indexes that need creating. You then See what effects you've had and maybe repeat the process. Gail explains all, in a two-part article. Read more...

Grant Fritchey

Understanding More Complex Query Plans

In order to be able to tackle performance issues in SQL Server , and write effective SQL, it is essential to gain a sound understanding of execution plans. Grant's previous article described graphical execution plans for Simple SQL queries. He now moves on to cover some of the more complicated plans that every database programmer will see. Read more...

Brad McGehee

How to Identify Slow Running Queries with SQL Profiler

With SQL Server Profiler, it is easy to discover all those queries that are running slowly. Once poorly performing queries are identified, there comes the harder task of speeding them up. Once again, the Profiler can provide a lot of information that can help diagnose and resolve these performance problems. Brad describes this essential part of the process of performance-tuning in an article taken from a chapter to his new book, Mastering SQL Server Profiler. Read more...

Grant Fritchey

Graphical Execution Plans for Simple SQL Queries

Learning how to read and analyze execution plans takes time and effort. But once you gain some experience, you will find them an essential skill for getting to grips with performance issues in SQL Server Queries. Grant here describes the range of execution plans for different simple SQL Queries. Read more...

Mario Broodbakker

Investigating SQL Server 2008 Wait Events with XEVENTS

Some reasons for the slow-running of database applications aren't obvious. Occasionally, even the profiler won't tell you enough to remedy a problem, especially when a SQL Statement is being forced to wait. Now, in SQL Server 2008, come XEvents, which allow you to look at those wait events that are slowing your SQL Statements. Mario Broodbakker continues his series about SQL Server Wait Events SQL Server 2008 wait event based performance analysis using XEvents Read more...

Grant Fritchey

Execution Plan Basics

Every day, out in the various discussion boards devoted to Microsoft SQL Server, the same types of questions come up again and again: Why is this query running slow? Is my index getting used? Why isn't my index getting used? Why does this query run faster than this query?. The correct response is probably different in each case, but in order to arrive at the answer you have to ask the same return question in each case: have you looked at the execution plan? Read more...

Grant Fritchey

SQL Server Performance Crib Sheet

Grant Fritchey provides an eagle-eye view of effective tools, strategies and techniques for SQL Server performance measurement, tuning and testing. Read more...

Mario Broodbakker

Taking the Guesswork out of SQL Server Performance Profiling Part 2

SQL 2005 wait event statistics are a good step forward, but are only useful for isolated testing, and to get a global impression on how the SQL Server is spending its time. Mario Broodbakker demonstrates why it would be much better if SQL Server collected those statistics per session and per subtask. Read more...

Mario Broodbakker

SQL Server Wait Events: Taking the Guesswork out of Performance Profiling

Measuring what is actually happening is always the best course of action when investigating performance issues on databases, rather than relying on cache hit ratios, or best practices, or worst of all, guesswork. This article introduces some techniques that will allow you to pinpoint exactly where the performance issues are in your system, so you'll know exactly where to spend your time (and money) in solving them. Read more...

Grant Fritchey

SQL Server Performance Testing

When faced with two viable solutions to a badly compromised database design, one using clustered indexes and the other compound primary keys, Grant Fritchey took the only sensible route: he gathered hard performance data... Read more...

Andy Warren

Performance tuning tips for database developers

Performance tuning is not easy and there aren’t any silver bullets, but you can go a surprisingly long way with a few basic guidelines. Read more...

Phil Factor
Searching for Strings in SQL Server Databases

Sometimes, you just want to do a search in a SQL Server database as if you were using a search engine like Google.... Read more...

 View the blog

Most Viewed

Beginning SQL Server 2005 Reporting Services Part 1
 Steve Joubert begins an in-depth tour of SQL Server 2005 Reporting Services with a step-by-step guide... Read more...

Ten Common Database Design Mistakes
 If database design is done right, then the development, deployment and subsequent performance in... Read more...

SQL Server Index Basics
 Given the fundamental importance of indexes in databases, it always comes as a surprise how often the... Read more...

Reading and Writing Files in SQL Server using T-SQL
 SQL Server provides several "standard" techniques by which to read and write to files but, just... Read more...

Concatenating Row Values in Transact-SQL
 It is an interesting problem in Transact SQL, for which there are a number of solutions and... Read more...

Why Join

Over 400,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.