You need to sign in to do that
Don't have an account?
Uves Ravat
Too many soql query????
Hi,
How can i make this soqgl query more efficent so i dont hit any govner limits
String query;
if(contractIds == null || contractIds.size() == 0)
query = 'Select id FROM Ceto_Contract__c WHERE (Status__c = :statusActive OR Status__c = :statusPending) AND (Contract_Expiration_Date__c > :runDate OR Contract_Expiration_Date__c = null) AND (Cancellation_Date__c > :runDate OR Cancellation_Date__c = null)';
if(Test.isRunningTest())
query += ' limit 1';
return query;
Thanks
I think he's saying that the Ceto_Contract__c has more than 10k rows, and he's hitting that limit.
All Answers
You need to post all of your code to get assistance on this. The code you posted by itself wouldn't hit any governor limits.
-Andy
Here is the whole query andy,
String query;
if(contractIds == null || contractIds.size() == 0)
query = 'Select id FROM Ceto_Contract__c WHERE (Status__c = :statusActive OR Status__c = :statusPending) AND (Contract_Expiration_Date__c > :runDate OR Contract_Expiration_Date__c = null) AND (Cancellation_Date__c > :runDate OR Cancellation_Date__c = null)';
else
query = 'Select id FROM Ceto_Contract__c WHERE (Status__c = :statusActive OR Status__c = :statusPending) AND (Contract_Expiration_Date__c > :runDate OR Contract_Expiration_Date__c = null) AND (Cancellation_Date__c > :runDate OR Cancellation_Date__c = null) AND id IN :contractIds';
if(Test.isRunningTest())
query += ' limit 1';
return query;
Thanks
Uves
Not just the query - that by itself won't hit any governor limits. How you are iterating through the results of that query would be more applicable. SOQL / DML in loops, etc.
-Andy
I think he's saying that the Ceto_Contract__c has more than 10k rows, and he's hitting that limit.