<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Persistent Connections</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd.incompatibilities.html">Incompatibilities</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqlnd.stats.html">Statistics</a></div> <div class="up"><a href="book.mysqlnd.html">Mysqlnd</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="mysqlnd.persist" class="chapter"> <h1>Persistent Connections</h1> <p class="para"> <em class="emphasis">Using Persistent Connections</em> </p> <p class="para"> If <em>mysqli</em> is used with <em>mysqlnd</em>, when a persistent connection is created it generates a <em>COM_CHANGE_USER</em> (<em>mysql_change_user()</em>) call on the server. This ensures that re-authentication of the connection takes place. </p> <p class="para"> As there is some overhead associated with the <em>COM_CHANGE_USER</em> call, it is possible to switch this off at compile time. Reusing a persistent connection will then generate a <em>COM_PING</em> (<em>mysql_ping</em>) call to simply test the connection is reusable. </p> <p class="para"> Generation of <em>COM_CHANGE_USER</em> can be switched off with the compile flag <em>MYSQLI_NO_CHANGE_USER_ON_PCONNECT</em>. For example: </p> <div class="example-contents"> <div class="cdata"><pre> shell# CFLAGS="-DMYSQLI_NO_CHANGE_USER_ON_PCONNECT" ./configure --with-mysql=/usr/local/mysql/ --with-mysqli=/usr/local/mysql/bin/mysql_config --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --enable-debug && make clean && make -j6 </pre></div> </div> <p class="para"> Or alternatively: </p> <div class="example-contents"> <div class="cdata"><pre> shell# export CFLAGS="-DMYSQLI_NO_CHANGE_USER_ON_PCONNECT" shell# configure --whatever-option shell# make clean shell# make </pre></div> </div> <p class="para"> Note that only <em>mysqli</em> on <em>mysqlnd</em> uses <em>COM_CHANGE_USER</em>. Other extension-driver combinations use <em>COM_PING</em> on initial use of a persistent connection. </p> </div> <hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="mysqlnd.incompatibilities.html">Incompatibilities</a></div> <div class="next" style="text-align: right; float: right;"><a href="mysqlnd.stats.html">Statistics</a></div> <div class="up"><a href="book.mysqlnd.html">Mysqlnd</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>