massive sql queries changes for updated db