Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How should columns be ordered for performance?

Status
Not open for further replies.

jconner

Programmer
Oct 26, 2003
6
US
Is there any particular way that you should order the columns in your tables to enhance performance? I'm guessing that indexed columns should be first, but other than that does it really matter? I was under the impression that SQL Server stored the data it's own way (fixed length data first, variable length data next) so does column order matter? Should numeric columns be first?

What about if you need to add a column to an existing table? Where should you put it?

Thanks for the help!

Jeremy
 
Shouldn't matter.
See for how data is stored and accessd and get a copy of
Inside SQL Server by Kalen Delaney.

If you add a column it will always be added at the end.

Far more important is which columns are indexed and the order in which they appear in the index and the datatype.
Note that you have to decide whether a query needs an index i.e. is the gain offered by the index worth the performance loss for inserts/updates.
More indexes may mean more fragmentation - especially with clustered indexes.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top