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 into big blobs as they get created by customers.
So if there are 100 entities right now I'll store them in blob and create helper entity for this blob like
class BlobRange
{
long fromId; // Comment.id
long toId; // Comment.id
String blobKey;
}
Next time background task would find biggest BlobRange.toId
and would fetch new chunk of Comment
whose id
is greater than BlobRange.toId
, which in this example would be greater than 100.
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.