If
we write parent-to-child queries then SOQL query rows limits will apply to both
parent rows + only if child records that are linked to the parent. Below example
explains the same.
1 | Select Name, (Select Name From Contacts) From Account LIMIT 20 |
Results: Returned records 1 - 20 of 20 total records in 0.063 seconds:
Download the results from Github: LINK
Before understanding how we are going to count the limit, please download the Results.xlsx file from the above link and see the results:
1 2 3 4 | System.debug('Before Consumed---- '+Limits.getQueryRows());
List<Account> accList = [Select Name, (Select Name From Contacts) From Account
LIMIT 20];
System.debug('After Consumed---- '+Limits.getQueryRows());
|
03:30:41.21 (22363384)|USER_DEBUG|[1]|DEBUG|Before Consumed---- 0 03:30:41.21 (36764256)|USER_DEBUG|[5]|DEBUG|After Consumed---- 30
If we observe the Results.xlsx file, you will see only 20 rows but in debug logs, rows consumed will show as "30".The reason is, internally it is using the below formula
Rows consumed = (Total rows returned) + (child records having parent)
tHiNk gooD and dO thE bEsT.........MANJU NATH 🌝
missflorZpuncro Curby Montague https://wakelet.com/@hotchtrucenan838
ReplyDeletesornitechso