August 21, 2010 at 7:47 pm
Hi,
I work with MSSQL 2000. When creating tables I never paid attention to the order and type of columns. Last week a co-worker mentioned that it is best to place fixed length data types first, followed by variable length columns
For example, if I have a table with have a few integer/date columns and a few varchar, he suggested to place varchar last.
Is it really better this way? If so, could someone explain in detail why?
Thank you!
August 22, 2010 at 10:25 am
sql_er (8/21/2010)
Hi,I work with MSSQL 2000. When creating tables I never paid attention to the order and type of columns. Last week a co-worker mentioned that it is best to place fixed length data types first, followed by variable length columns
For example, if I have a table with have a few integer/date columns and a few varchar, he suggested to place varchar last.
Is it really better this way? If so, could someone explain in detail why?
Thank you!
Not as far as I am aware - I believe that was true in the 6.0/6.5 days, but hasn't been that way since then.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
August 22, 2010 at 10:31 am
sql_er (8/21/2010)
Last week a co-worker mentioned that it is best to place fixed length data types first, followed by variable length columns
No, not at all. Order of columns in the table is utterly irrelevant. The way SQL stores them on the page is fixed data types first, then variable lengths, but that's done no matter what the 'order' they are defined in looks like.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 22, 2010 at 2:43 pm
That is what I assumed an intelligent system would do - thanks for the clarification!
August 22, 2010 at 8:13 pm
GilaMonster (8/22/2010)
sql_er (8/21/2010)
Last week a co-worker mentioned that it is best to place fixed length data types first, followed by variable length columnsNo, not at all. Order of columns in the table is utterly irrelevant. The way SQL stores them on the page is fixed data types first, then variable lengths, but that's done no matter what the 'order' they are defined in looks like.
There's one I didn't know. Have a got a Paul or MS link for that? I'd like to read up on it. Thanks, Gail.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 23, 2010 at 2:12 am
Jeff Moden (8/22/2010)
There's one I didn't know. Have a got a Paul or MS link for that?
Got a Paul link (or three).
http://sqlskills.com/BLOGS/PAUL/post/Inside-the-Storage-Engine-Anatomy-of-a-record.aspx
http://sqlskills.com/BLOGS/PAUL/post/Inside-the-Storage-Engine-Anatomy-of-a-page.aspx
Everything in his category 'On disk structures' is worth a read or two.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 23, 2010 at 5:54 am
GilaMonster (8/23/2010)
Jeff Moden (8/22/2010)
There's one I didn't know. Have a got a Paul or MS link for that?Got a Paul link (or three).
http://sqlskills.com/BLOGS/PAUL/post/Inside-the-Storage-Engine-Anatomy-of-a-record.aspx
http://sqlskills.com/BLOGS/PAUL/post/Inside-the-Storage-Engine-Anatomy-of-a-page.aspx
Everything in his category 'On disk structures' is worth a read or two.
Outstanding. Thanks, Gail.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 23, 2010 at 6:05 am
Here's why I specifically wanted a "Paul" reference... I knew he'd get into...
Using DBCC IND and DBCC PAGE to examine a row in detail
It's too bad the comments are closed on those articles. I'd love to post a "thanks". Guess I'll have to do it in-person at PASS this year.
Thanks again, Gail.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 23, 2010 at 7:51 am
Excellent, thanks for the links as well!!!
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply