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 Boo开发者_运维技巧lean 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.
Rhubarb, in general you never want to change the order of columns once they have been created as you can break a lot of things and cause massive havok in a production system when you try to change a huge table this way.
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.
精彩评论