I have 26 accounts and 24 contact records in the org and running a SOQL query on them (fetching Accounts along with contacts). Found that if SOQL for loop is used then the child records fetched in the query don't contribute to the governor limit (refer to screenshot below) unlike standard SOQL queries.
SOQL for loop:
for(Account a : [Select Id, Name, (Select Id, Name from Contacts) From Account]) {}
The number of query rows counted is :
Standard SOQL query:
List<Account> acc = [Select Id, Name, (Select Id, Name from Contacts) From Account];
The number of query rows counted is :
I tried finding this in documentation, but couldn't find it. Can someone please validate if my observation is correct or not?