[英]Mysql table design advice
I have a general question about MySQL database table design. 我对MySQL数据库表设计有一个一般性问题。 I have a table that contains ~ 650 thousand records, with approximately 100 thousand added per year.
我有一个表,包含约65万条记录,每年大约增加10万条记录。 The data is requested quite frequently, 1.6 times per second on average.
数据请求非常频繁,平均每秒请求1.6次。
It has the following structure right now 现在具有以下结构
id port_id date product1_price product2_price product3_price
1 1 2012-01-01 100.00 200.00 155.00
2 2 2012-01-01 NULL 150.00 255.00
3 3 2012-01-01 300.00 NULL 355.00
4 1 2012-01-02 200.00 250.00 355.00
5 2 2012-01-02 400.00 230.00 255.00
Wouln't it be better to store the data in this manner? 以这种方式存储数据会更好吗?
id port_id date product price
1 1 2012-01-01 1 100
1 2 2012-01-01 1 200
1 3 2012-01-01 1 300
1 1 2012-01-02 1 240
Advantages of the alternative design: 替代设计的优点:
Disadvantages of the alternative design: 替代设计的缺点:
In both cases we have id
column as PRIMARY_KEY and UNIQUE key on combination of port_id
and date
. 在这两种情况下,我们在
port_id
和date
组合上都有id
列作为PRIMARY_KEY和UNIQUE键。
So the question is: which way to go? 所以问题是:走哪条路? Disk space does not matter, the speed of the queries is the most important aspect.
磁盘空间无关紧要,查询速度是最重要的方面。
Thank you for your attention. 感谢您的关注。
It seams, that will depend on definition of product
table. 它接缝,这将取决于
product
表的定义。
If product table is statically compound of maximum three parts, then changing the current design won't help much. 如果产品表由最多三部分组成的静态组合,那么更改当前设计将无济于事。
Although the current design smells bad but that will be a business dependent analysis. 尽管当前的设计很难闻,但这将是与业务相关的分析。
BTW change must be done with caution on the side effects with product table and its usages. BTW更改必须谨慎对待产品表及其用法的副作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.