Sql Server Performance And Order Of Fields

情到浓时终转凉″ 提交于 2020-01-02 04:00:21

问题


does the order of fields creation in a table effect on the performance of commands on the table? If the answer is yes, can anyone discuss it?

For example i have create a table like this

create table Software(int id,alpha datetime,beta datetime,title nvarchar(100),stable datetime,description nvarchar(200) )

if i change it to

create table Software(int id,alpha datetime,beta datetime,stable datetime,description nvarchar(200),title nvarchar(100) )

Is there any performance effect ?

Is it clear?


回答1:


The field order makes no difference whatsoever (if the fields are always the same of course)

The on-disk structure will remain the same pretty much regardless. Simply:

  • header
  • fixed length columns
  • null bitmap
  • variable length columns

All you're doing above is rearranging some columns inside the "fixed length" and "variable length" sections. However, the same processing is required to retrieve them no matter which order they are in.

See Paul Randal's article




回答2:


No. This will not affect performance.




回答3:


The field order can have a very subtle effect on performance and how often maintenance operations will have to take place. In the grand scheme of things, it would be a significantly better use of your time to:

  • Build/Test indexes
  • Restructure queries
  • Partition tables (horizontally & vertically)
  • Alter the filegroup architecture

That is not an exhaustive list.

You didn't mention if you've already tuned any of those things and are still needing to squeeze some extra ms out of the process.



来源:https://stackoverflow.com/questions/5839459/sql-server-performance-and-order-of-fields

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!