2

Say I'm executing a query with a subquery in the select clause:

select Name, (select FirstName, LastName from Contact) 
from Account where BillingStateCode='NY'

Per this, I'm limited to 10 QueryLocator cursors. But per this (and I'm pretty sure it works the same with SOAP), I get a separate QueryLocator to paginate a list of Contacts for each Account record.

Do child QueryLocator objects count toward the total number of cursors, and if so, won't I immediately blow by the limit, as each batch will have 200-2000 accounts?

Also, does Salesforce really create a separate DB cursor for each Account object to retrieve the child Contact records? That seems horribly inefficient...

3
  • I'm looking for documentation to back this up, but you do have a few incorrect assumptions: (a) a QueryLocator is only generated if the results must be paginated, (b) other limits provided by the platform will make it challenging to craft a query large enough to create enough QueryLocators to wipe out the original query, and (c) most data sets aren't big enough to generate tons of sub-query QueryLocators. I've worked with large data sets and I don't think I've ever seen an invalid query locator from simply using sub-queries.
    – sfdcfox
    Apr 12, 2016 at 23:09
  • @sfdcfox I'm using Account and Contact as example, but if I understand the documentation correctly (which maybe I don't), then 11 matching Account objects with 201 Contacts in each and a batch size of 200 would result in 11 open cursors, right? Apr 13, 2016 at 21:44
  • You know... Let me try it and see. I don't think I've ever intentionally tried to break the cursor limit this way.
    – sfdcfox
    Apr 13, 2016 at 21:45

0

You must log in to answer this question.

Browse other questions tagged .