google-app-engine


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.

Related Links

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

Categories

HOME
google-app-engine
grok
facebook-oauth
jpa
eslint
jmeter
alexa-skills-kit
interface
battery
package
vscode-extensions
pdfbox
soa
tail
gembox-spreadsheet
jetty
pcl-crypto
fhir
appcelerator-studio
startup
redis-sentinel
gkturnbasedmatch
atlassian
flatpak
android-intent
bitnami
dreamweaver
sse
react-toolbox
exploit
moses
progress-bar
exchangewebservices
vex
android-sugarorm
gojs
gnat-gps
batching
sharepoint-workflow
swagger-php
alphabetical
openalpr
z-notation
connection-pool
railstutorial.org
opensmpp
postgresql-8.4
claims
outputcache
monkey-testing
clarifai
sonarlint-eclipse
wcftestclient
chai-as-promised
convex-optimization
corruption
java-6
colorbar
cd-burning
mathcad
simplepie
tinkerpop3
jodd
drawstring
realsense
kendo-upload
toast
qt5.2
dock
nutiteq
bufferedinputstream
user-permissions
cosine-similarity
viewer
rickshaw
unix-socket
build-script
memset
syndicationfeed
hibernate-entitymanager
inappsettingskit
beaker-testing
pagedown
web-farm
faye
usertype
virtualpathprovider
google-maps-mobile
landscape-portrait
automationelement
tmx
collectionviewsource
tabpanel
scrollbars
request-headers
wysiwym
online-storage

Resources

Encrypt Message