Add has_id() to db.data in the new backend

Also speed up has_id() and all_book_ids()