Optimize queries needed for volume calculation