Does SOQL query get consumed when querying from an empty set?
Yes, even though the Set<Id> accountIds
is empty, 1 SOQL query will be executed and will be counted against the 100 SOQL queries limit.
On a similar note, the code below won't be counted as 1 DML statement:
List<Account> accounts = new List<Account>();
update accounts;