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') 
  • 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). May 12, 2018 at 14:41

1 Answer 1


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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .