Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 indexes questions
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Flowing Fount of Yak Knowledge

1410 Posts

Posted - 09/20/2010 :  06:03:37  Show Profile  Reply with Quote
I have been playing around with indexes.
I used to think that all id identity fields were automatically indexes but I see they are not and adding the index can really speed up queries.

now my question is - up to how many indexes can you have on a table?

anything else really important to know about indexes?

Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 09/20/2010 :  06:33:43  Show Profile  Reply with Quote
you can have 1 clustered index and 999 non clustered indexes (why you'd want this many is beyond me, but they are there for you), but you do also have the include option in SQL 2005 and above.
Go to Top of Page

Flowing Fount of Yak Knowledge

1410 Posts

Posted - 09/20/2010 :  06:42:43  Show Profile  Reply with Quote
but do you gain if you keep adding non clustered indexes?
does it still make searching faster against these fields? or should you limit it to 2 or 3?
Go to Top of Page

Flowing Fount of Yak Knowledge

South Africa
4507 Posts

Posted - 09/20/2010 :  06:58:25  Show Profile  Visit GilaMonster's Homepage  Reply with Quote
Originally posted by esthera

but do you gain if you keep adding non clustered indexes?

Maybe, depending on whether the indexes are useful for the queries or not.

SQL will add an index when you create primary key or unique constraints. So an identity column won't get an index, but an identity primary key will.

Indexing's nor a simple area. Some reading for you: - 3 part series, read all three - lots of stuff here, not necessarily in a logical order though.

Gail Shaw
SQL Server MVP
Go to Top of Page

Transact Charlie
Flowing Fount of Yak Knowledge

United Kingdom
3451 Posts

Posted - 09/20/2010 :  07:20:47  Show Profile  Visit Transact Charlie's Homepage  Reply with Quote
Especially note that a foreign key does *not* add a relevant index. many people assume that it does.

Msg 3903, Level 16, State 1, Line 1736
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000