Difference between Database.query() and Database.getQueryLocator

Difference between Database.query() and Database.getQueryLocator

Database.query()
We can retrieve up to 50,000 records.
If VF page doesn’t have read only attribute, use Database.query().
In Batch Apex, if we use Database.query(), it supports 50,000 records only.
 
Database.getQueryLocator
We can retrieve up to 10,000 records.
If VF page have read only attribute, use Database.getQueryLocator().
In Batch Apex, if we use Database.getQueryLocator(), it supports upto 50 million records.

Leave a Reply