guard against extreme memory consumption

Instead of fetching all unsent notifications, we only fetch their ids. Once we
have the ids, we process them in batches of 1000.