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 |
asqldeveloper
Starting Member
17 Posts |
Posted - 2013-08-20 : 21:39:18
|
I understand that the order of columns doesnt change performance but if my primary key is made of two or more columns and its not the first columns, but spreadout in the table, would that affect index seeks or scans or affect performance. Example below.Lets say my primarykey is OfficeName, OfficeCounty, OfficeStateand my table script isCREATE TABLE OFFICE(OfficeName,OfficeIsActive,OfficeIsWalkableDistance,OfficeCanBeReachedByPhone,OfficeSupportsPrinter,OfficeCounty,OfficeManagerFirstName,OfficeManagerLastName,OfficeState).As you can see my primary key is spread out in the table, does it matter? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2013-08-22 : 11:22:31
|
The order of the columns within the index does matter, as has been pointed out already. The order of those columns within the table does not (I'm not sure if that was your question or not). Moving OfficeCounty and/or OfficeState to be "earlier" in the table would have no effect on your index performance.=================================================The cure for anything is salt water -- sweat, tears, or the sea. -Isak Dinesen |
|
|
asqldeveloper
Starting Member
17 Posts |
Posted - 2013-08-23 : 13:37:45
|
KoolYou got my question right and Thanks for answering it. Thats what I thought, but wanted to make sure. I do know that the order of index matters. Thanks.I designed in Erwin, but I guess there is a check box which you should uncheck (and its set by default) which makes it create the table in random colum order. If you uncheck it, it would create in the exact column order you designed in Erwin.Why on earth that it would be set to scramble by default is beyond me. |
|
|
|
|
|
|
|