- August 3, 2018 at 12:37 pm #30981
What is database.getQuerylocator in Salesforce?
What is database.getQuerylocator in Salesforce?
Database QueryLocator database.getQueryLocator() Records Salesforce Methods SOQL Query
August 8, 2018 at 6:54 am #31244Hello Avnish,
Database.getQueryLocator returns a Query Locator that runs your selected SOQL query returning list that can be iterated over in bathc apex or used for displaying large sets in VF (allowing things such as pagination).
The query locator can return upto 50 million records and should be used in instances where you want to bactha a high volume of data up (pagination or batch apex). The database.query method should be used in instances where you are wanting to do a dynamic runtime SOQL query for your code.
Hope that helps.
Thanks.
September 16, 2018 at 5:15 pm #34581Hi,
Database.QueryLocator object when you are using a simple query (SELECT) to generate the scope of objects used in the batch job. If you use a querylocator object, the governor limit for the total number of records retrieved by SOQL queries is bypassed but we can retrieve up to 10,000 records.
To add more –
Database.query():
We can retrieve up to 50,000 records.
If VF page has read-only attribute, use Database.getQueryLocator().
In Batch Apex, if we use Database.query(), it supports 50,000 records only.String fieldName = ‘Name,Phone’;
String dynQuery = ‘select Id ‘ + fieldName + ‘ From Account’;
Database.query(dynQuery);Hope this helps.
September 16, 2018 at 5:46 pm #34596 - AuthorPosts
Home Salesforce Questions & Answers Salesforce Questions and Answers What is database.getQuerylocator in Salesforce?
Related Salesforce Questions
- 1Making SOQL Query Process Faster in salesforce?
- 4Difference between synchronous and asynchronous in apex
- 1if the field is blank more than 10 days of record creation in Salesforce, we need to send a mail.
- 1What is the Method to call a Salesforce Trigger from the main class?
- 2What are the types of custom settings in Salesforce? What is the advantage of using custom settings?
- 2How can we lock record using SOQL so that it cannot be modified by other user in salesforce?
- 1How to make Formula Field indexed in Salesforce?
- 2How many records can a select query return? How many records can a SOSL(Salesforce Object Query Language) query return?
- 2How can we change the grant access using role hierarchy for standard objects?
- 2What are some Salesforce Apex best practices?
- 6How to pass Dynamic parameter in SOQL where clause, while mapping in Webmerge?
- 3Difference between database.query() and database.getQueryLocator() in Salesforce?
Salesforce Question Tags
- Salesforce Apex x 573
- Salesforce Development x 435
- Salesforce Visualforce Page x 432
- Salesforce SOQL x 298
- Salesforce Records x 287
- Salesforce Visualforce x 256
- Salesforce Customization x 217
- Salesforce Lightning x 211
- Salesforce Trigger x 189
- Salesforce Apex Code x 183
- Salesforce Apex Class x 159
- Salesforce Lightning Components x 159
- Difference x 151
- Salesforce Force.com x 149
- Salesforce Objects x 148
- active 1 hour, 33 minutes ago
- active 4 hours, 47 minutes ago
- active 18 hours, 3 minutes ago
- active 18 hours, 39 minutes ago
- active 20 hours, 6 minutes ago