Oracle 5.0 Reference Manual page 2602

Table of Contents

Advertisement

select($mysqli, "slave_1", "/*Partition_A*/");
?>
6804 - slave_0 - SELECT CONNECTION_ID() AS _thread, 'slave1' AS _hint FROM DUAL
2442 - slave_1 - SELECT CONNECTION_ID() AS _thread, 'slave2' AS _hint FROM DUAL
6804 - slave_0 - /*Partition_A*/SELECT CONNECTION_ID() AS _thread, 'slave1' AS _hint FROM DUAL
6804 - slave_0 - /*Partition_A*/SELECT CONNECTION_ID() AS _thread, 'slave1' AS _hint FROM DUAL
By default, the plugin will use all configured master and slave servers for query execution. But if a
query begins with a SQL hint like /*node_group*/, the plugin will only consider the servers listed
in the
node_group
only be executed on slave_0.
20.7.6.5. Concepts
Copyright 1997-2012 the PHP Documentation Group. [2230]
This explains the architecture and related concepts for this plugin, and describes the impact that
MySQL replication and this plugin have on developmental tasks while using a database cluster.
Reading and understanding these concepts is required, in order to use this plugin with success.
20.7.6.5.1. Architecture
Copyright 1997-2012 the PHP Documentation Group. [2230]
The mysqlnd replication and load balancing plugin is implemented as a PHP extension. It is written
in C and operates under the hood of PHP. During the startup of the PHP interpreter, in the module
init phase of the PHP engine, it gets registered as a
methods.
At PHP runtime, it inspects queries sent from mysqlnd (PHP) to the MySQL server. If a query
is recognized as read-only, it will be sent to one of the configured slave servers. Statements
are considered read-only if they either start with SELECT, the SQL hint
slave had been chosen for running the previous query, and the query started with the SQL hint
*ms=last_used*/. In all other cases, the query will be sent to the MySQL replication master server.
For better portability, applications should use the
MYSQLND_MS_SLAVE_SWITCH
constants, instead of their literal values, such as /*ms=slave*/.
The plugin handles the opening and closing of database connections to both master and slave servers.
From an application point of view, there continues to be only one connection handle. However,
internally, this one public connection handle represents a pool of network connections that are
managed by the plugin. The plugin proxies queries to the master server, and to the slaves using
multiple connections.
Database connections have a state consisting of, for example, transaction status, transaction settings,
character set settings, and temporary tables. The plugin will try to maintain the same state among
all internal connections, whenever this can be done in an automatic and transparent way. In cases
where it is not easily possible to maintain state among all connections, such as when using
TRANSACTION, the plugin leaves it to the user to handle.
20.7.6.5.2. Connection pooling and switching
Copyright 1997-2012 the PHP Documentation Group. [2230]
The replication and load balancing plugin changes the semantics of a PHP MySQL connection handle.
The existing API of the PHP MySQL extensions (mysqli, mysql, and PDO_MYSQL) are not changed
Mysqlnd replication and load balancing plugin (mysqlnd_ms)
for query execution. Thus,
, and
MYSQLND_MS_LAST_USED_SWITCH
queries prefixed with
SELECT
mysqlnd
plugin to replace selected mysqlnd C
MYSQLND_MS_MASTER_SWITCH
2582
/*Partition_A*/
or a
/*ms=slave*/
,
predefined mysqlnd_ms
BEGIN
will
/

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents