简体   繁体   English

MySQL 的 InnoDB - 避免为单个事务刷新日志缓冲区?

[英]MySQL's InnoDB - avoid flushing log buffer for a single transaction?

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?是否可以以编程方式告诉 MySQL 不要只为当前事务立即刷新日志缓冲区,而不管innodb_flush_log_at_trx_commit设置如何?

Let's say you generally want ACID compliance so that your data is safe from any power/hardware faults.假设您通常需要 ACID 合规性,以便您的数据免受任何电源/硬件故障的影响。 So you have innodb_flush_log_at_trx_commit = 1所以你有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.但是在您的应用程序中,您有一个特定的 INSERT 查询需要快速返回,并且具有相同级别的完整性保护并不那么重要。 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?您可以通过 SQL 查询或 PHP 的 PDO 中的某些内容以编程方式进行吗?

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.我认为答案是它无法完成——除非你愿意只为有问题的特定表切换到 MyISAM。

I'm not sure if this will do exactly what you want, but check out INSERT DELAYED .我不确定这是否会完全符合您的要求,但请查看INSERT DELAYED

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM