What actually gets replicated to a MySQL slave?
I have two MySQL servers configured in a multi-master replication setup. Each is a slave and master to the other. My application requires that some large queries be ran in the background, and the results of these queries would be used to populate a table. I figured, I could have these large queries run on one server, and the application front-end use the other. This way, the application wouldn't be slowed while the server is running these queries.
These queries are very large INSERT .... 开发者_JS百科SELECT
. With my replication setup, it seems that when one server finishes the query, instead of just sending the INSERTs to the slave, it has the slave run the original large INSERT/SELECT.
Is this actually happening? Or is there a way to see what commands were sent to the slave from the master to verify this is the behavior? The only way I can tell is from CPU load.
Is there a way for the slave to only get the resulting INSERT from an INSERT... SELECT ran on the master?
Is this actually happening?
Probably.
Or is there a way to see what commands were sent to the slave from the master to verify this is the behavior?
Well, you could deconstruct the binlog, but I expect that reading up on replication format options will be much less headache-inducing.
You're probably in statement-based mode which has been the default for ages. You want to be in row-based mode or hybrid mode, if those INSERT INTO ... SELECT
statements are a pain. These options are available only in MySQL 5.1 or better.
The actual queries are run. The only way around you INSERT...SELECT is to break them up yourself. Run the select, store the result in memory, then do a bulk insert.
精彩评论