SQL SERVER – Clustered Index on Separate Drive From Table Location

How to improve performance of SQL Server Queries is a common topic of discussion among many of us. Much has been said, much has been discussed. Few days back, I had an interesting discussion with one of the Junior developers regarding performance improvement of SQL Server Queries. We discussed on how by using a separate hard drive for several database objects can right away improve performance. I suggested him that non clustered index and tempdb can be created on a separate disk to improve performance.

No sooner had I given my suggestion than I received a question – What will happen if we can create clustered index on a separate drive from the table on which it is built.

My answer is : No! It is not possible at all.

Let us first be clear about the difference between a clustered and a non clustered index.

Clustered Index

  • Only 1 allowed per table
  • Physically rearranges data in the table to conform to the index constraints
  • For use on columns that are frequently searched for ranges of data
  • For use on columns with low selectivity

Non-Clustered Index

  • Up to 249 (for SQL Server 2005) and 999 (for SQL Server 2008) allowed per table
  • Creates a separate list of key values with pointers to the location of the data in the data pages
  • For use on columns that are searched for single values
  • For use on columns with high selectivity

A table devoid of primary key index is called heap, and here data is not arranged in a particular order, which gives rise to issues that adversely affect performance. Data must be stored in some kind of order. If we put clustered index on it then the order will be forced by that index and the data will be stored in that particular order.

Reference : Pinal Dave (http://blog.sqlauthority.com)

About these ads

14 thoughts on “SQL SERVER – Clustered Index on Separate Drive From Table Location

  1. Just to clarify – it is possible to create a clustered index on a different filegroup (or drive) than the original one. It just moves the table to the new filegroup, without moving its corresponding indexes.

    For example, say that you create a table with a clustered index and five nonclustered indexes all in the primary filegroup. If you drop that clustered index and create a new clustered index on a new filegroup, the table will move over to it – but the five nonclustered indexes won’t.

    Like

  2. Hi Brent,

    Very correct. In fact I think what you said really goes well with this post.

    I will create example of the same with due credit to you and will post in new blog post.

    Kind Regards,
    Pinal

    Like

  3. Hi Pinal,

    Please leave the msg regarding the examples of clustered index n non clustered index n what is the meaning of primary file group n all

    Thanks,
    Narenndra

    Like

  4. Hi Amit,

    Yes we can have multiple .mdf or .ldf files (we can have even different extensions)
    Just Right Click on DB goto Properties and click on Files Options… from here you can add different log and data files

    You can also restrict the size of each chunk you created
    Hope u got it

    Like

  5. After creating index’s i was able to reduce time of a query from one whole night to 3 minutes

    Many people talk about index’s but dont tell others how simple it is to create them

    1) Just right click a table

    2) Select Indexces/keys

    3) Click add

    4) use the dropdown hence to create index on a column you are using in the query

    5) add index to all the columns used in query by clicking
    add button

    Like

  6. Pingback: SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Day 12 of 31 Journey to SQLAuthority

  7. Pingback: SQL SERVER – Database Worst Practices – New Town and New Job and New Disasters Journey to SQLAuthority

  8. Pingback: SQL SERVER – Weekly Series – Memory Lane – #034 | Journey to SQL Authority with Pinal Dave

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s