Not sure about performance difference, but I think it is way more robust than the current check_max_id method