Always use next_after from last key

The sorting used by the database und perl might be different and
re-checking the order might lead to strange results.