查询简单,在 VF 页面控制器中耗时 1 分钟,在 Developer Console 中执行时不到 1 秒。查询正在搜索超过 50,000 条记录。为什么查询运行时间有如此巨大的差异?
String s = '123456';
List<Registration__c> regs =
[select id, name
from Registration__c
where name =: s or speical_number__c =: s limit 1];
以下是调试日志的摘录:
开发者控制台:
12:22:39.063 (63557000)|SOQL_EXECUTE_BEGIN|[2]|Aggregations:0|select id, name from Registration__c where (name = :tmpVar1 or speical_number__c = :tmpVar2) limit 1
12:22:39.263 (263582000)|SOQL_EXECUTE_END|[2]|行数:0
VF 页面控制器:
12:17:08.148 (3148592000)|SOQL_EXECUTE_BEGIN|[633]|Aggregations:0|select id, name from Registration__c where (name = :tmpVar1 or speical_number__c = :tmpVar2) limit 1
12:18:07.350 (62350264000)|SOQL_EXECUTE_END|[633]|行数:0