Home > SQL Server Tips > Database Administration > Partition indexes for improved SQL Server 2005 performance
SQL Server Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE ADMINISTRATION

Partition indexes for improved SQL Server 2005 performance


Serdar Yegulalp, Contributor
08.01.2006
Rating: -3.00- (out of 5)


Expert advice on database development
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


Index partitioning is one of a number of new features introduced in SQL Server 2005 as a way to distribute the load for a given index across multiple files, which can enhance parallelism or improve index performance in other ways.

[TABLE]

Earlier editions of SQL Server accomplished index partitioning with partitioned views. Queries to and changes against tables could be constrained in certain ways by a view, so only needed physical files would be queried or modified. For instance (this is an arbitrary example but it suits our needs), if you had 26 tables for a customer database, one for each letter of the alphabet, you could use a partitioned view to aggregate the results from all of the tables and use WITH CHECK constraints to update only the needed tables. You could run a query against all customers whose names begin with "B" and the partitioned view would know only to poll the "B" table.

The downside of partitioned views is that they must be created and managed manually. In SQL Server 2005, there's greater abstraction between partitions, tables and data, so they can be manipulated independently.

Also new is index partitioning, where the index (or indexes) for a given table are partitioned or constrained across multiple files and filegroups. Here I've assembled some basic guidelines for how to set up and use index partitioning; the exact details for how to do this are described in SQL Server 2005 Books Online.

[TABLE]

There are two ways to create an index with partitioned data: Partition the index as the data is partitioned or partition the index separately. Which partition scheme to use should depend on how your data is accessed and updated.

In the first setup your index is "partition aligned." By default any newly-created index on a partitioned table will have the same partitioning as the table itself. This is best if you:

Take the example where a partition arrangement covers a year of dat


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Microsoft SQL Server Performance Monitoring and Tuning
Performance implications of transaction log autogrowth in SQL Server
The short course on how SQL Server really works
Determining the source of full transaction logs in SQL Server
Improving SQL Server full-text search performance
New GROUP BY option provides better data control in SQL Server 2008
Microsoft SQL Server 2008 Resource Governor primer
Examining data files when SQL Server tempdb is full
Testing transaction log autogrowth behavior in SQL Server
Meeting business needs with SQL Server full-text search
Using dynamic management views to improve SQL Server index effectiveness

Microsoft SQL Server 2005 (Yukon)
SQL Server Reporting Services Fast Guide
SQL Server Service Broker Tutorial and Reference Guide
Tips for tuning SQL Server 2005 to improve reporting performance
SQL Server consolidation: Why it's an optimization technique
Parent-child dimensions in SQL Server 2005 with Analysis Services MDX
Enforcing data integrity in a SQL Server database
SSIS error message due to installation problem on SQL Server 2005
Should you upgrade to SQL Server 2005 or SQL Server 2008?
Basics for working with DATETIME and SMALLDATETIME in SQL Server 2005
How to configure Database Mail in SQL Server 2005 to send mail
Microsoft SQL Server 2005 (Yukon) Research

Database Administration
Top load balancing methods for SQL Server
Performance implications of transaction log autogrowth in SQL Server
The keys to database backup protection for SQL Server
Understanding transparent data encryption in SQL Server 2008
Working with sparse columns in SQL Server 2008
Determining the source of full transaction logs in SQL Server
Implementing SQL Server 2008 FILESTREAM functionality
Improving SQL Server full-text search performance
Using the OPENROWSET function in SQL Server
New replication features in SQL Server 2008 and what they mean to you

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
contiguity  (SearchSQLServer.com)
contiguous  (SearchSQLServer.com)
drilldown  (SearchSQLServer.com)
hashing  (SearchSQLServer.com)
hybrid online analytical processing  (SearchSQLServer.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


a split up according to months, where the date is used as a primary key. Partitioning the index this way speeds up date lookups since SQL Server can quickly determine where a given key may be in the index.

There are times you won't always want to use a partition-aligned arrangement, possibly in cases where you have a unique index key that does not contain the table's partitioning column. For instance, if we were using the above A to Z partitioning scheme but the index key for the tables was a GUID or auto-increment number rather than the customer name, you could keep the index in its own partition so it's not aligned with the table. In any case if you explicitly put the index on a different filegroup, partitioning will not match the table.

If you're partitioning data that has a unique index, the column used for partitioning be the same used for the unique index key. If your unique partition index is a client ID number, for instance, that will be the same column used to partition the index key as well.

[TABLE]

Partitions are made up of two things: partition function and partition scheme. The first represents how data itself is split across different partitions. For instance, in the A to Z example, the data is partitioned according to each letter of the alphabet as 26 separate partition functions.

A scheme represents how each partition in the partition function is mapped to a filegroup. If our A to Z table has "A" data stored in a physical file in one filegroup and the "A" index stored in another physical file in the same filegroup, a partition-aligned index can help speed up and parallelize access to both the data and indexes. That way multiple CPUs can work on different partitions or physical files. (You can parallelize things further by placing indexes and data on separate physical spindles, if you have them.)

[TABLE]

Building partition-aligned indexes takes memory and uses space in tempdb. Many database administrators don't set tempdb's space allotments to anything beyond the default when they install SQL Server, and the time and effort it takes to auto-expand tempdb can put a crimp in performance. Also, indexes that are partitioned differently are built using different memory allocation schemes: a partition-aligned index is built with one sort table at a time, while a nonaligned index is built with all its sort tables at the same time.

Microsoft states in Books Online that the minimum size for each sort table per partition is 40 pages of 8 KB per page, so a nonaligned partitioned index with 26 partitions (using the previous A to Z example) would require 1,040 pages -- approximately 4.25 MB of memory. A nonaligned index would only need 163,840 bytes. For the most robust SQL Server installations this shouldn't be a problem, but be mindful if you're dealing with extremely large partitioning schemes and working with multiple partitioning schemes at one time.

About the author: Serdar Yegulalp is editor of the Windows Power Users Newsletter. Check it out for the latest advice and musings on the world of Windows network administrators -- and please share your thoughts as well!

Rate this Tip
To rate tips, you must be a member of SearchSQLServer.com.
Register now to start rating these tips. Log in if you are already a member.




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



SQL Server Development - .NET, C#, T-SQL, Visual Basic
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts