Possibly the naming AggregateQueries is very misleading. My first thought was it should be related to a GROUP BY clause - but it seems to be different. I did not try it on my own but found this article could help with the clarification:
https://bartoszborowiec.wordpress.com/2014/12/12/soql-subqueries-and-limits/
Following this article, the limit seems to count subselects at the SELECT clause
select name,
( select id, name, Contact__r.Name
from AccountContacts__r
where name != null )
from Account
but not in the WHERE clause
select name
from Account
where id in ( select Account__c from AccountContact__c )
Try the complete code
@isTest
private class SubqueriesTest {
@isTest
static void testQueriesAgainstLimits() {
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 0, Limits.getQueries() );
List<Account> accounts = [
select name
from Account
];
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 1, Limits.getQueries() );
}
@isTest
static void testSubqueriesInWhereClauseAgainsLimits() {
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 0, Limits.getQueries() );
List<Account> accounts = [
select name
from Account
where id in ( select Account__c from AccountContact__c )
];
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 1, Limits.getQueries() );
}
@isTest
static void testSubqueriesInSelectClauseAgainsLimits() {
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 0, Limits.getQueries() );
List<Account> accounts = [
select name,
( select id, name, Contact__r.Name
from AccountContacts__r
where name != null )
from Account
];
System.assertEquals( 1, Limits.getAggregateQueries() );
System.assertEquals( 1, Limits.getQueries() );
}
@isTest
static void testSubqueriesAgainsLimits() {
System.assertEquals( 0, Limits.getAggregateQueries() );
System.assertEquals( 0, Limits.getQueries() );
List<Account> accounts = [
select name,
( select id, name, Contact__r.Name
from AccountContacts__r
where name != null )
from Account
where id in (select Account__c from AccountContact__c)
];
System.assertEquals( 1, Limits.getAggregateQueries() );
System.assertEquals( 1, Limits.getQueries() ) ;
}
}