【发布时间】:2011-04-21 05:54:02
【问题描述】:
这是我的设置:
Windows Server 2008 R2
MySql 5.1.562
PHP 5.3.2
教义 1.2
任何人都知道为什么我的查询需要大约一秒钟来执行一个简单的查询。
echo date("Y-m-d H:i:s", time()) ."::::::" . microtime(true)."<br />";
$q = Doctrine_Query::create()
->from("Ordering")
->where("client_id = ?",array($_SESSION["UserID"]));
$ResProduct = $q->execute();
echo date("Y-m-d H:i:s", time()) ."::::::" . microtime(true)."<br />";
这是 2 echo 的结果,显示执行查询需要多长时间。
2011-04-21 01:48:24::::::1303364904.8051
2011-04-21 01:48:25::::::1303364905.8418
另外,数据库中没有数据。
编辑
我直接在mysql控制台执行查询,很快得到结果
mysql> select * from Ordering where client_id = 2;
+----+------------+-------+------+-----------+
| id | product_id | price | qty | client_id |
+----+------------+-------+------+-----------+
| 7 | 1 | 0.89 | 20 | 2 |
+----+------------+-------+------+-----------+
1 row in set (0.00 sec)
【问题讨论】:
-
喜欢标题“我的学说真的很慢”... ;-D
-
我不明白你为什么在 php 5.3.2 上使用
microtime_float()。使用microtime(true)。 -
谢谢,我不知道 microtime(true)。不错:)
标签: php mysql performance doctrine-1.2