Is it guaranteed that auto-incremented ID of new entity always bigger than existing IDs ?
Basically I want to periodically dump entity (e.g. Comment) in background task
Afaik, no. IDs seem to be allocated in blocks (see here). I've personally seen IDs allocated something like this: 1001, 2001, 1002, 3001, 2002, etc.. It seems that they are incremented contiguously within a block, but there are several blocks used in parallel.
So you can not rely on this to check for new entities.
Instead use Query Cursors for this. Create a timestamp property (can be a unix timestamp of type long
) on Comment that records when Comment was created. Then use query and cursors to detect new entities.