MySQL 的 InnoDB - 避免刷新单个事务的日志缓冲区?
是否可以以编程方式告诉 MySQL 不要立即刷新当前事务的日志缓冲区,无论 innodb_flush_log_at_trx_commit 设置如何?
假设您通常需要 ACID 合规性,以便您的数据免受任何电源/硬件故障的影响。所以你有 innodb_flush_log_at_trx_commit = 1
但在你的应用程序中,你有一个特定的 INSERT 查询需要快速返回,并且它具有相同级别的完整性保护并不那么重要。您可以仅针对该查询/事务跳过刷新(在事务结束时)吗?您可以通过 SQL 查询或 PHP PDO 中的某些内容以编程方式完成此操作吗?
Is it possible to programmatically tell MySQL not to flush the log buffer immediately just for the current transaction, regardless of the innodb_flush_log_at_trx_commit
setting?
Let's say you generally want ACID compliance so that your data is safe from any power/hardware faults. So you have innodb_flush_log_at_trx_commit = 1
But in your application, you have one particular INSERT query that needs to return quickly, and it's not as important for it to have the same level of integrity protection. Can you skip the flush (at the end of its transaction) just for that query/transaction? And can you do it programmatically, with an SQL query or something in PHP's PDO?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为答案是它无法完成 - 除非您愿意仅针对相关的特定表切换到 MyISAM。
I think the answer is that it can't be done - unless you are willing to switch to MyISAM just for the particular table in question.
我不确定这是否完全符合您的要求,但请查看
插入延迟
。I'm not sure if this will do exactly what you want, but check out
INSERT DELAYED
.