Simple query, taking 1 minute in the VF page controller, and less than 1 second when executed in the Developer Console. There are more than 50,000 records that the query is searching through. Why such a dramatic difference in the query run time?
String s = '123456';
List<Registration__c> regs =
[select id, name
from Registration__c
where name =: s or speical_number__c =: s limit 1];
Here are the excerpts from the debug logs:
Developer Console:
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]|Rows:0
VF Page Controller:
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]|Rows:0