Fixing SQL timeout