简体   繁体   中英

Does column ordering in databases affect performance?

I am using Django with MySql. I have a CharField with max length of 64 as the 2nd to last column, and a Boolean as the last column. Will reversing the order of these provide better optimization of space?

If at all, probably not significantly enough for you to care about it. MySQL would have some serious work to do if that were the case.

If there is any performance impact (and since I can't seem to find much information on it, probably not), you shouldn't have to worry about it until you hit thousands and thousands of users a day. Column order would be one of the smallest optimizations you would end up making.

大黄,一般来说,创建列后就永远不希望更改它们的顺序,因为当您尝试以这种方式更改巨大的表时,您可能会破坏很多事情并在生产系统中造成巨大的麻烦。

It's not a good idea to change the order of columns once they have been defined. When I add new columns to a table, I always add them at the end. This makes it easier if you need to make global changes througout your applications and provides for better documentation since you can easily tell in what order new columns were added. I always comment columns with: date added/changed, description, reason.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM