mysql proxy 问题 效率太差 慢 郁闷
一,前言
装了,mysql proxy后感觉挺爽的,因为代码端就不要那边烦了。哈哈。但是实际运用时发现他慢啊,能明显感觉出来。郁闷
二,测试mysql proxy的效率情况
1),按常规方法,连接数据库
<?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->prepare($sql); $sth->execute(); $result = $sth->fetchAll(PDO::FETCH_ASSOC); print_r($result); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } ?>
测试结果:
2),用mysql proxy,连接数据库
<?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->prepare($sql); $sth->execute(); $result = $sth->fetchAll(PDO::FETCH_ASSOC); print_r($result); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } ?>
测试结果:
由上面二个测试结果,可以看出来,用了mysql proxy速度降了不是一点点,降了好几倍啊。我在网上找了一下,原因没有找到。汗。