我在结果集中有4000行的查询。如果我在像Heidisql这样的查询浏览器中执行此查询,我会在0.5秒内获得所有4000行。如果我在我的Internet浏览器中查看Query:alter Table 'TableName' drop constraint PK__TableName__30242045
,我会在30秒内获得所有数据。这是一个很大的区别!
我试过mysqli和PDO这是同样的问题。
这是一个简单的查询,来自twotable(带有左连接),有18列。
我的查询中有一个位置,所有标准都被编入索引(2索引!)
我有一个带有php 5.3的mysql 5.1
这里是代码:
print_r($result);
这是EXPLAIN的结果:
$db_handle->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db_handle->setAttribute(PDO::ATTR_AUTOCOMMIT, false);
$time_start = microtime(true);
$sqlCFf = "
SELECT ....
";
$result_set = $db_handle->query($sqlCFf);
$result = $result_set -> fetchAll();
print_r ($result);
$time_end = microtime(true);
$time_res = $time_end - $time_start;
如果有人想要在PHP中更快地找出输出?
提前THX答案 0 :(得分:0)
使用EXPLAIN
('Bad input argument to theano function with name "<stdin>:1" at index 0(0-based)', 'Wrong number of dimensions: expected 2, got 1 with shape (2,).')
了解EXPLAIN的输出
EXPLAIN SELECT * FROM tablename
答案 1 :(得分:0)
据我所知,任何编程语言的打印结果都会耗费大量的资源/时间。
从你的代码:
$result = $result_set -> fetchAll();
print_r ($result);
//you try to record the end time after printing then it will took longer and not a reliable approach
$time_end = microtime(true);
尝试重新安排这样的代码:
$result = $result_set -> fetchAll();
//put it here, then it will record the end time before printing, which is the right way to benchmark
$time_end = microtime(true);
print_r ($result);