speed improvements by grouping sql requests