好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

mysql proxy 问题 效率太差 慢 郁闷

一,前言

装了,mysql proxy后感觉挺爽的,因为代码端就不要那边烦了。哈哈。但是实际运用时发现他慢啊,能明显感觉出来。郁闷

二,测试mysql proxy的效率情况

1),按常规方法,连接数据库

&lt;?php /* * Created on 2009-12-8 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */

 

$dsn = 'mysql:dbname=test;host=192.168.1.75;port=3306'; $user = 'root'; $password = '';

try {

$dbh = new PDO($dsn, $user, $password);

$sql = "SELECT id, name, sex ". " FROM test ";

$sth = $dbh-&gt;prepare($sql); $sth-&gt;execute();

$result = $sth-&gt;fetchAll(PDO::FETCH_ASSOC); print_r($result);

} catch (PDOException $e) { echo 'Connection failed: ' . $e-&gt;getMessage(); }

?&gt;  

测试结果:

mysql 正常连接

2),用mysql proxy,连接数据库

&lt;?php /* * Created on 2009-12-8 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */

测试结果:

 

$dsn = 'mysql:dbname=test;host=127.0.0.1;port=8888'; $user = 'root'; $password = '';

try {

$dbh = new PDO($dsn, $user, $password);

$sql = "SELECT id, name, sex ". " FROM test ";

$sth = $dbh-&gt;prepare($sql); $sth-&gt;execute();

$result = $sth-&gt;fetchAll(PDO::FETCH_ASSOC); print_r($result);

} catch (PDOException $e) { echo 'Connection failed: ' . $e-&gt;getMessage(); }

?&gt;  

 

mysql proxy 连接数据库

由上面二个测试结果,可以看出来,用了mysql proxy速度降了不是一点点,降了好几倍啊。我在网上找了一下,原因没有找到。汗

查看更多关于mysql proxy 问题 效率太差 慢 郁闷的详细内容...

  阅读:43次