Persistent Connections
Using Persistent Connections
If mysqli is used with mysqlnd,
when a persistent connection is created it generates a
COM_CHANGE_USER
(mysql_change_user()) call on the server. This
ensures that re-authentication of the connection takes place.
As there is some overhead associated with the
COM_CHANGE_USER call, it is possible to switch this
off at compile time. Reusing a persistent connection will then
generate a COM_PING (mysql_ping)
call to simply test the connection is reusable.
Generation of COM_CHANGE_USER can be switched off
with the compile flag
MYSQLI_NO_CHANGE_USER_ON_PCONNECT. For example:
Or alternatively:
Note that only mysqli on mysqlnd
uses COM_CHANGE_USER. Other extension-driver
combinations use COM_PING on initial use of a
persistent connection.