我的rails应用程序是使用mysql数据库设置的。
当我做一个简单的发现时,例如:
Pin.find(:all).size
将导致以下
Pin Load (130.1ms) SELECT `pins`.* FROM `pins`
EXPLAIN (0.6ms) EXPLAIN SELECT `pins`.* FROM `pins`
EXPLAIN for: SELECT `pins`.* FROM `pins`
+----+-------------+-------+------+---------------+------+---------+------+-------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+-------+-------+
| 1 | SIMPLE | pins | ALL | NULL | NULL | NULL | NULL | 33385 | |
+----+-------------+-------+------+---------------+------+---------+------+-------+-------+
1 row in set (0.00 sec)
=> 33385
如何关闭EXPLAIN SELECT以便:
Pin.find(:all).size
将返回
Pin Load (1719.6ms) SELECT `pins`.* FROM `pins`
=> 43774
答案 0 :(得分:3)
在环境/开发集
中config.active_record.auto_explain_threshold_in_seconds = nil
这将关闭自动解释。