Activity Forums Salesforce® Discussions What are the limitations on using a semi-join in a batch apex query locator in salesforce?

  • What are the limitations on using a semi-join in a batch apex query locator in salesforce?

    Posted by Deepak on October 7, 2019 at 11:18 am

    What are the limitations on using a semi-join in a batch apex query locator in salesforce?

    Laveena replied 5 years, 1 month ago 2 Members · 1 Reply
  • 1 Reply
  • Laveena

    Member
    October 7, 2019 at 12:39 pm

    Hi Deepak,

    If the Detail__c part of this query exceeds your 100,000 rows, you will receive an exception, before you even try to receive the Master__c records. I'm not sure exactly what you're going for, but here are a couple of approaches:

    Query on the Master object with a subquery on the related Details within the execute() method. You might run with a limit on the batch size if that is a safe way to limit how many Detail rows you'll receive. I have run this kind of process with as few as 1 records per batch.
    Query on the Detail object but sort by Master Id, so you can finish and update objects as you go along. Implementing Database.stateful will allow you to keep a running tally of any incomplete objects between execute runs. This will eliminate the requirement that one Master object fit within the governor restrictions of one execute() mathod.

    Thanks

     

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos