Solved

What column to use for clustered index?

Posted on 2013-06-29
2
421 Views
Last Modified: 2013-07-01
Hello,

I am struggling with the question which column to use for my clustered index? So far, if I have the table:

id, firstname, lastname

I always automatically gave identity(1,1) and clustered index (primary key) on that one. But - is this always correct? I practically never seek by id. There are always some other columns that I usually search on. In above scenario: if I search by firstname - does clustered index on id has any impact on my query? Or it would be the same if I just left whole table as a heap? Same goes if I use my search by lastname ?

What about this table:

id, ssid, firstname, lastname

Is there a point to have id column at all in the table? Or is it better to put id out and have clustered index on ssid?


cherrs, F
0
Comment
Question by:AntonioRodrigo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 250 total points
ID: 39287063
a clustered index dictate the physical sequence of the data in a table.

if your clustered index is by lastname and you do a "select * where lastname between 'm' and 'p' order by lastname", it will be optimal.

but if you insert a lot of data, you will get a lot of page split which will reduce performance

it is sometimes difficult to find the sweet spot/index
0
 
LVL 16

Accepted Solution

by:
EvilPostIt earned 250 total points
ID: 39289261
It depends on your entire database to be honest, if there are relational tables then this is a good reason as while it isn't data that the user would see it is still used quite a lot to match rows.

Your key should be unique though as if it isnt the row will be made larger as a field called a unqueifier will be added to the page.

As per emoreau's comments you should think about how the data is going to be used, inserted, deleted in the future as if you choose the position now it could cause you troubles down the road!
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
The reason that corporations and businesses use Windows servers is because it supports custom modifications to adapt to the business and what it needs. Most individual users won’t need such powerful options. Here I’ll explain how you can enable Wind…
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question