更新IN MYSQL InnoDB百万条记录

发布于 2024-12-15 16:31:52 字数 162 浏览 3 评论 0原文

MYSQL Innodb 更新问题:

一旦我收到一条记录的响应(状态),我需要将响应更新到一个非常大的表(大约 100 万条记录,并且会不断增加),并且这种情况可能会每秒发生 100 次。我可以知道会有任何性能问题吗?或者我可以修改的任何设置以避免表锁定或查询减慢问题。

谢谢。

MYSQL Innodb Update Issue:

Once I receive a response (status) for a record ,I need to update the response to a very large table (Approximate 1 million records and will keep increasing),and this will keep happen may be 100 times per second. May I know will there any performance issue? OR any setting I can modify to avoid table locking or query slowing issue.

Thanks.

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

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

发布评论

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

评论(3

土豪我们做朋友吧 2024-12-22 16:31:52

听起来像是一个设计问题。

您应该在数据记录中存储指向状态记录的引用,而不是存储百万条数据记录的标志(状态记录更新更改的标志)。因此,当您更新状态记录时,不需要进一步的数据库操作。另外,当您扫描数据记录时,您应该加入状态记录(如果需要显示)。如果状态记录更改经常发生,则比更新数百万条数据记录要好。

也许,我错了,你应该解释数据库(结构、表记录计数)以获得更准确的答案。

It sounds like a design issue.

Instead storing the flag (which the status-record update changes) for million data-records, you should store a reference in data-records pointing to the status-record. So, when you update the status-record, no further db operation required. Also, when you're scanning through the data-records, you should JOIN for the status-records (if it's needed to display). If status-record change occurs often, it's better than update millions of data-records.

Maybe, I'm wrong, you should explain the db (structure, table record counts) for more accurate answers.

何止钟意 2024-12-22 16:31:52

如果您使用 MyISAM 存储引擎存储表,那么您的表将 每次更新都锁定

但是,InnoDB 存储引擎能够锁定各个行< /a>.

如果您需要同时更新多个记录,InnoDB 可能会更好。

If you store your table using the MyISAM storage engine, then your table will lock with every update.

However, the InnoDB storage engine is capable of locking individual rows.

If you need to UPDATE multiple records simultaneously, InnoDB may be better.

亣腦蒛氧 2024-12-22 16:31:52

数据库上的任何索引(尤其是聚集索引)都会减慢写入速度。

索引可以加快读取速度,但会减慢写入速度。大多数数据库的读取次数多于写入次数,但听起来您的数据库的写入次数要多得多。

Any indexes you have on the database (especially clustered indexes) will slow your writes down.

Indexes speed up reading, but they slow down writing. Most databases get read more than written to, but it sounds like yours gets written to much more.

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