reorders update_all_metrics! to be more order of operations efficient

1. ensures all matching metric rows exist
2. tries to auto-detect aggregate functions and collect bad guesses
3. runs singular metrics and bad guesses in the same batch. (IMPROVED)
4. runs custom sql