MySQL:优化具有很多列的表 [英] MySQL: Optimize table with lots of columns
问题描述
我的用户表有26列以上,这正常吗?当该用户表引起我注意时,数据库已被标准化为第3级.是否有26列可以使用?在设计数据库时应该使用其他优化技术吗?
My user table has over 26 columns, is that normal? The db is already normalized to the 3rd level when this user table caught my eye. Is having 26 columns ok or is there some other optimization technique you use when designing your db that I should be doing?
更多:对表进行分区是什么意思?
More: What's meant by Partitioning your table?
推荐答案
26列没什么问题,但是如果很少使用它们,那就有所不同了.
there's nothing wrong with 26 columns but if they are rarely used then its different.
您可以使用较少的一列,而不是使用26列,并使用序列化字符串对它们进行分组.
instead of using 26 columns, you take the one that you use less and group them using a serialize string.
将字段更改为文本字段,然后在代码中可以反序列化它们并使用它们.如果需要更新,则可以从代码中更新数组,然后对其进行序列化并将其保存到数据库中.
change the field to a text field and then in your code you can de-serialize them and use them. if you need to update, you update the array (from your code) and then serialize it and save it to the database.
这篇关于MySQL:优化具有很多列的表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!