To check the SOQL consumption if an empty collection is passed in WHERE clause, I ran below code, also making a DML in the last line (to check both SOQL and DML)
Set<Id> accountIds = new Set<Id>();
// passing empty collection of ids (accountIds) to feed the below SOQL
Account accnts = [SELECT id FROM Account WHERE Id IN: accountIds];
and got this result
Number of SOQL queries: 1 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
So, working with empty collection in such scenario, the results suggest that
- One SOQL will be consumed and count against SOQL limits, hence an
if(collection.size()) check should be placed to check the size of the collection before feeding it to the SOQL to avoid counting against SOQL limits.
- No DML will be counted, which means,
if(collection.size()) check would be an unnecessary before the DML statement.