1

I am using a query to retrieve records in Workbench but everytime I run the query the number of records return is different. There are about 800000 records.

What would be the reason?

SELECT Opportunity.recordtype.name, LastModifiedDate, Id,Product_Name__c,Opportunity.CloseDate, CreatedDate FROM OpportunityLineItem
WHERE Opportunity.isclosed!= TRUE 
AND (Opportunity.RecordType.Name = 'A' OR Opportunity.RecordType.Name = 'B') 
ORDER BY OPPORTUNITY.ID
  • 3
    Different by how much? Obviously the number of matching records could change depending on activity in your environment (i.e., users changing records in production or an active QA sandbox). – John Towers May 12 '18 at 14:41
0

If user is creating or updating Opportunity records when you are firing the query then you will get different results.

Secondly, your query must be selective and you must think how many records to want to display through workbench.

Do you need to test to see if first 2000 records are displaying properly or you need to take extract of entire dataset?

Since your org contains high volume of data then you always think about query optimization. Refer Query & Search Optimization Cheat Sheet

Rather than using isClosed !=true, use isClosed = false as Not equals negates indexing.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.