with groups queries, reducing queries to 1 per table