[英]MySql number of columns and parameter size affect on performance
I have looked at similar questions such as this one Does number of columns affect MYSQL speed? 我看过类似的问题,例如这一列是否会影响MYSQL的速度?
I will try to ask my question with more specification as it is slightly different. 我会尝试用更多的规范来提问我的问题,因为它略有不同。
I have the option of having a table like this; 我可以选择这样的桌子;
UserID | Parameter 1 | Parameter 2
The table will NOT have any relational SQL performed on it. 该表不会对其执行任何关系SQL。 The queries will only read/write Parameter 1 OR Parameter 2 for a group of UserIDs. 查询将仅读取/写入一组UserID的参数1或参数2。
Parameter 1 will be required more than 10 times as often as Parameter 2 参数1的频率是参数2的10倍
Parameter 1 will store a data string of up to 1000 characters 参数1将存储最多1000个字符的数据字符串
Parameter 2 will store a data string of up to 100000 characters 参数2将存储最多100000个字符的数据字符串
I have a choice of format for these so I think TEXT(1000) or Blob for Parameter 1 and MEDIUMTEXT(100000) or MEDIUMBLOB for Parameter 2 would be valid. 我可以选择这些格式,所以我认为参数1和MEDIUMTEXT(100000)的TEXT(1000)或Blob或参数2的MEDIUMBLOB都是有效的。 Note I just need to read/write these - I am not sure what the format choice would do to DB performance (minor question). 注意我只需要读/写这些 - 我不确定格式选择对DB性能的影响(次要问题)。
My main question is this; 我的主要问题是这个; given the frequency of access to Parameter 1 and Parameter 2, the independence of the Parameters, and given the much greater size of Parameter 2, should I have one table; 给定参数1和参数2的访问频率,参数的独立性,以及参数2的大小,我应该有一个表;
UserID | Parameter 1 | Parameter 2
OR two tables; 或两个表;
UserID | Parameter 1
UserID | Parameter 2
This is an edit to make things clearer. 这是一个让事情更清晰的编辑。 I am interested in the performance difference of the two table options given the previous description. 我对前面描述的两个表选项的性能差异感兴趣。 I am especially concerned that the inclusion of the larger and less used Parameter 2 will have a significant impact on the performance when accessing Parameter 1. You may consider that the effect if there are 1000s of rows. 我特别担心的是,当访问参数1时,包含较大且较少使用的参数2将对性能产生重大影响。如果存在1000行,则可以考虑效果。
Premature optimization. 过早优化。 Go with whichever is easier from a programming viewpoint. 从编程角度来看更容易。
Obsessing over a little detail like this will just cause you to lose time you could actually be implementing your program. 对这样的一些细节进行痴迷只会让你失去实际执行程序的时间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.