I have exposed apex rest service where I received 1369 records to be inserted into one custom object called PUP. Before inserting into PUP, i have to multiply these rows by 3 ( 1 record from external system map to 1 role and I need to create records for 3 roles so 1*3) so total # of records is now 4107. Then I am inserting into PUP objects as follows
As per salesforce documentation , trigger accepts only 200 records at a time. So trigger will fire 21 times on this object ( 4107 /200 =20.33).
The trigger written on this object is bulkified. But since trigger is firing 21 times and trigger variables are not reseting after each 200 rows inserting and it is firing in single transaction scope, I am getting "too many SOQL queries :101" error.
Note: Trigger on PUP object has some business logic which fire query on other object. So assuming we have 6 queries on PUP trigger for both insert and update trigger event, the total # of soql queries will be 21 * 6 = 126