Optimize updating the database to ignore rows