GQL Random Record [duplicate]
Possible Duplicate: Fetching a random record from the Google App Engine Datastore? How can I efficiently pick a random database record using GQL? Eg. I have a Quotes Model and I need to pick a random quote every time. The question follows from my understanding that the ID attribute cannot be guaranteed to be auto-incremented with every insertion in the production server.
The auto-generated ids are guaranteed to be unique, but not sequential or strictly increasing. There are already many questions about this on stackoverflow, and in the groups. There are several common solutions: Generate and store a random number on your entities as you create them, then pick a random number and look (via a query) for the closet record(s) to it. Implement some mechanism to ensure your entity ids are "densely" populated, then fetch within the known range using keys. Periodically generate random lists of the entities and return entities from those lists. This may take the form of a stack that entities are popped off of, or as actual lists that are returned. What you do not want to do is choose a random offset. Offset is very inefficient because the datastore still has to scan over all of the skipped entities.
Uploading >10k files as static content to GAE
Dealing with large zip uploads and extracting using google cloud
Android Studio not recognizing gradle 2.10
How to solving ImportError: No module named scraping
Securely providing external service credentials to Google App Engine?
Arduino make GET request to Google app engine
Is my GAE Search corrupt?
Jinja2 reuse templates for new and edit
Using QuerySplitter in Google Datastore to load chunks of a known size
Can you explain what the app engine context interface is?
How to ensure that my entity will never be an orphan?
GAE custom Go runtime - internal.flushLog error
Google Datastore - Search Optimization Technique
Can't lease tasks by service account
Why custom domain “myapp.com” which replaces “myapp.appspot.com” took so long to load when comparing to “myapp.appspot.com”?
Does objectify have a get_or_insert equivalent