17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

9<br />

<strong>SQL</strong> Ser ver Storage and<br />

Index Str uctures<br />

Indexes are a critical part of your database planning and system maintenance. They provide <strong>SQL</strong><br />

<strong>Server</strong> (and any other database system for that matter) with additional ways to look up data and<br />

take shortcuts to that data’s physical location. Adding the right index can cut huge percentages of<br />

time off your query executions. Unfortunately, too many poorly planned indexes can actually increase<br />

the time it takes for your query to run. Indeed, indexes tend to be one of the most misunderstood<br />

objects that <strong>SQL</strong> <strong>Server</strong> offers, and therefore, they also tend to be one of the most mismanaged.<br />

We will be studying indexes rather closely in this chapter from both a developer’s and an administrator’s<br />

point of view, but in order to understand indexes, you also need to understand how data<br />

is stored in <strong>SQL</strong> <strong>Server</strong>. For that reason, we will also take a look at <strong>SQL</strong> <strong>Server</strong>’s data-storage<br />

mechanism.<br />

<strong>SQL</strong> Ser ver Storage<br />

Data in <strong>SQL</strong> <strong>Server</strong> can be thought of as existing in something of a hierarchy of structures. The<br />

hierarchy is pretty simple. Some of the objects within the hierarchy are things that you will deal<br />

with directly, and will therefore understand easily. A few others exist under the covers, and while<br />

they can be directly addressed in some cases, they usually are not. Let’s take a look at them one by one.<br />

The Database<br />

OK — this one is easy. I can just hear people out there saying, “Duh! I knew that.” Yes, you probably<br />

did, but I point it out as a unique entity here because it is the highest level of storage (for a given<br />

server). This is also the highest level at which a lock can be established, although you cannot explicitly<br />

create a database-level lock.<br />

A lock is something of a hold and a place marker that is used by the system. As you do development<br />

using <strong>SQL</strong> <strong>Server</strong> — or any other database for that matter — you will find that understanding<br />

and managing locks is absolutely critical to your system.

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

Saved successfully!

Ooh no, something went wrong!