Reputation: 47
I have an innodb mysql db, I wanted to know if the query cache gets flushed on any change in the table or it gets flushed when there is a change to only those records?
I have a large table that gets modified every few minutes so I am wondering how useful it is.
Thanks
Upvotes: 2
Views: 152
Reputation: 4179
I do not think you are talking about the Query Cache but about the Buffer Cache.
The query cache is a cache of the most recent SQL statements, these are never flushed to disk.
Flushing the buffer cache is not as important as flushing the buffer log. The log keeps track of the updated performed on the data inside your databse. It is used to recover the db in event of a failure i.e. when buffer cache is not flushed to disk.
There are 3 main ways to flush the bufferer log in InnoDB and they are controlled with the parameter innodb_flush_log_at_trx_commit
.
MySQL docs quote:
"If you can afford the loss of some of the latest committed transactions if a crash occurs, you can set the innodb_flush_log_at_trx_commit parameter to 0. InnoDB tries to flush the log once per second anyway, although the flush is not guaranteed. Also, set the value of innodb_support_xa to 0, which will reduce the number of disk flushes due to synchronizing on disk data and the binary log."
Source: http://dev.mysql.com/doc/refman/5.1/en/innodb-tuning.html
Hope that helps
Upvotes: 2