Skip to main content
Hello,

We have a problem while we are inserting small bunch of data to Salesforce via Apex code. It takes 7500 milliseconds to insert it to database. Is this normal? Normally in Java you can insert 67 records into database less than 100 milliseconds. Are we doing something wrong? What is the best approach? 

Here is the code that where we insert Slot objects.  

//validSlots has only 67 records. But takes 7500 ms

if(validSlots != null && validSlots.size() > 0) {

insert validSlots;

}

Thanks,

Alper Ozdamar

Senior Software Engineer

 
8 answers
  1. Oct 18, 2019, 6:29 AM
    Hi Alper,

     

    I have gone through your code then I realized there is no need to check null condition because you already check size() > 0.

    Check below code

    if(validSlots.size() > 0) {

                    insert validSlots;

    }

    I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

    Thanks and Regards,

    Deepali Kulshrestha

    www.kdeepali.com
0/9000