一,前言
装了,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();
- }
- ?>
测试结果:
mysql 正常连接
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 连接数据库
由上面二个测试结果,可以看出来,用了mysql proxy速度降了不是一点点,降了好几倍啊。我在网上找了一下,原因没有找到。汗。
来源: http://blog.51yip.com/mysql/402.html