Using SQL to count the done tasks. Improves performance.