Explain database.querylocator vs simplequery.
I want to know what is the difference between Database.QueryLocator() and simple SOQL Query i.e.
Listinvent = [Select Id,Quantity__c,AccountId__c,Name,Expiry_Date__c From Inventory__c]; And
Database.getQueryLocator([Select Id,Quantity__c,AccountId__c,Name,Expiry_Date__c From Inventory__c]);
I want to know what the QueryLocator class is in Apex.. I went through this link but cannot understand its structure.
Database.QueryLocator : when used the governor limit for the total number of records retrieved by SOQL queries is bypassed. For example, a batch Apex job for the Account object can return a QueryLocator for all account records (up to 50 million records) in an org. Another example is a sharing recalculation for the Contact object that returns a QueryLocator for all account records in an org.
For the regular query you do have a limit of 50,000 rows per transaction