有什么方法可以让我获得MySQL查询的时间(特别是使用PHP)?完成查询所需的实际时间,即。
例如:棕色的结果1-10。(0.11秒)
我试着找一个例子,但没有结果。下面是我的代码示例:
// prepare sql statement
$stmt = $dbh->prepare("SELECT ijl, description, source, user_id, timestamp FROM Submissions WHERE MATCH (ijl, description) AGAINST (?)");
// bind parameters
$stmt->bindParam(1, $search, PDO::PARAM_STR);
// execute prepared statement
$stmt->execute();使用MyISAM表引擎进行当前全文搜索。任何帮助都是不可思议的。谢谢。
发布于 2011-03-11 01:08:25
$starttime = microtime(true);
//Do your query and stuff here
$endtime = microtime(true);
$duration = $endtime - $starttime; //calculates total time taken注意到,由于get_as_float参数为真,这将给您以秒(而不是微秒)为单位的运行时间到最近的微秒。请参阅这
发布于 2015-05-07 20:17:03
这可能对你有帮助
http://dev.mysql.com/doc/refman/5.0/en/show-profile.html
mysql> SET profiling = 1;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS t1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> CREATE TABLE T1 (id INT);
Query OK, 0 rows affected (0.01 sec)
mysql> SHOW PROFILES;
+----------+----------+--------------------------+
| Query_ID | Duration | Query |
+----------+----------+--------------------------+
| 0 | 0.000088 | SET PROFILING = 1 |
| 1 | 0.000136 | DROP TABLE IF EXISTS t1 |
| 2 | 0.011947 | CREATE TABLE t1 (id INT) |
+----------+----------+--------------------------+问候
发布于 2011-03-11 01:10:39
我现在可以告诉你们两种可能性:
希望这能有所帮助。
https://stackoverflow.com/questions/5267890
复制相似问题