The built-in read-write-split mechanism is very basic. Every
query which starts with
is considered a read request to be sent to a MySQL slave server.
All other queries (such as
are considered as write requests that are sent to the MySQL master server.
The build-in behavior can be overruled using
SQL hints, or a user-defined
The read-write splitter is not aware of multi-statements. Multi-statements
are considered as one statement. The decision of where to run the statement
will be based on the beginning of the statement string. For example, if
to execute the multi-statement
SELECT id FROM test ; INSERT INTO test(id) VALUES (1),
the statement will be redirected to a slave server because it begins with
INSERT statement, which is
also part of the multi-statement, will not be redirected to a master server.