Reduce SQL settings queries