Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2010-09-20 : 06:03:37
|
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? |
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2010-09-20 : 06:33:43
|
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. |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2010-09-20 : 06:42:43
|
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? |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2010-09-20 : 06:58:25
|
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:http://www.sqlservercentral.com/articles/Indexing/68439/ - 3 part series, read all threehttp://sqlinthewild.co.za/index.php/category/sql-server/indexes/ - lots of stuff here, not necessarily in a logical order though.--Gail ShawSQL Server MVP |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-20 : 07:20:47
|
Especially note that a foreign key does *not* add a relevant index. many people assume that it does.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
|
|
|