大型数据库表的设计技巧?

发布于 2024-12-08 14:21:02 字数 371 浏览 1 评论 0原文

这里是数据库新手。

我想规划一个销售发票数据库,其中每月将添加数百万条记录/行。
里面的数据不是那么重,只是一些信息,例如id,amount等...
问题是表需要非常(非常)频繁地更新。
我担心表会增长得如此之快,从而在未来减慢系统速度。
我正在寻找一般设计技巧,我应该如何更新这种表格。
我的架构中还有一些其他表,但该表是最重要且更新最频繁的表。
是否有任何设计/技巧/架构,这样我就不必直接更新该表。

这是我的简要平台。

Application : java/spring mvc
Database    : mysql
OS          : CentOS 6

A Database newbie here.

I would like to plan a sales invoice database in which millions of records/rows will be added a month.
The data inside is not that heavy but a few information like id,amount, etc...
The problem is that table needs to be updated very (very) frequently.
I am concerned that table will grow so quickly and slow down the system in the future.
I am looking for a general design tips how should I update that kind of table.
I have some other tables in my schema but that table is the most important one and the most frequently updated.
Is there any design/tip/architecture so I do not have to update that table directly.

Here is my platform in brief.

Application : java/spring mvc
Database    : mysql
OS          : CentOS 6

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光沙漏 2024-12-15 14:21:02

规则一:在速度变慢之前不要担心性能。

规则 2:将这些表规范化到至少 3NF

规则 3:如果有大量更新,请简化索引,不要声明唯一索引。

do something like:

id integer not null primary key auto_increment  <<-- simple primary key
amount decimal(10,2) not null
.....

规则4:表的大小不影响插入速度。 (除非您有唯一索引)

提示:使用 InnoDB。

Rule 1: don't worry about performance before slowness hits you.

Rule 2: normalize those tables up to at least 3NF

Rule 3: If you have lots of updates, go easy on the indexes and do not declare unique indexes.

do something like:

id integer not null primary key auto_increment  <<-- simple primary key
amount decimal(10,2) not null
.....

Rule 4: The size of a table does not affect the insert speed. (Unless you have unique indexes)

Tip: Use InnoDB.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文