Oracle 5.0 Reference Manual page 2610

Table of Contents

Advertisement

20.7.6.5.7. Read-write splitting
Copyright 1997-2012 the PHP Documentation Group. [2230]
The plugin executes read-only statements on the configured MySQL slaves, and all other queries on
the MySQL master. Statements are considered read-only if they either start with SELECT, the SQL
hint /*ms=slave*/, or if a slave had been chosen for running the previous query and the query
starts with the SQL hint /*ms=last_used*/. In all other cases, the query will be sent to the MySQL
replication master server. It is recommended to use the constants
MYSQLND_MS_MASTER_SWITCH
See also the
SQL hints are a special kind of standard compliant SQL comments. The plugin does check every
statement for certain SQL hints. The SQL hints are described within the
documentation, constants that are exported by the extension. Other systems involved with the
statement processing, such as the MySQL server, SQL firewalls, and SQL proxies, are unaffected by
the SQL hints, because those systems are designed to ignore SQL comments.
The built-in read-write splitter can be replaced by a user-defined filter, see also the
documentation.
A user-defined read-write splitter can request the built-in logic to send a statement to a specific
location, by invoking mysqlnd_ms_is_select.
20.7.6.5.8. Filter
Copyright 1997-2012 the PHP Documentation Group. [2230]
filters. PHP applications that implement a MySQL replication cluster must first identify a group of
servers in the cluster which could execute a statement before the statement is executed by one of the
candidates. In other words: a defined list of servers must be filtered until only one server is available.
The process of filtering may include using one or more filters, and filters can be chained. And they are
executed in the order they are defined in the plugins configuration file.
Available filters:
• Load balancing filters:
• Selection filter: user, user_multi, quality_of_service.
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
and
list of mysqlnd_ms
constants.
Note
The built-in read-write splitter is not aware of multi-statements. Multi-statements
are seen as one statement. The splitter will check the beginning of the
statement to decide where to run the statement. If, for example, a multi-
statement begins with
VALUES (1); ...
not read-only.
Version requirement
Filters exist as of mysqlnd_ms version 1.1.0-beta.
Explanation: comparing filter chaining to pipes
The concept of chained filters can be compared to using pipes to connect
command line utilities on an operating system command shell. For example,
an input stream is passed to a processor, filtered, and then transferred to be
output. Then, the output is passed as input to the next command, which is
connected to the previous using the pipe operator.
random
and roundrobin.
MYSQLND_MS_LAST_USED_SWITCH
SELECT 1 FROM DUAL; INSERT INTO test(id)
the plugin will run it on a slave although the statement is
2590
MYSQLND_MS_SLAVE_SWITCH
instead of /*ms=slave*/.
mysqlnd_ms constants
user filter
,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents