Reputation: 15
Using the GAE datastore, what option below would perform the best? (Assume that memcache is not available)
Option 1: DataModel: Entity User has some key, and an email address (the email can't be used as the key)
a) Perform a query on User that filters for a match by email
OR Option 2:
DataModel: Entity User has some key, Entity UserLogin has email address as key, and user key
a) Perform a get on UserLogin, then
b) Perform a get on User using the user key from UserLogin
Upvotes: 1
Views: 513
Reputation: 101149
Get operations are substantially faster than queries, not to mention cheaper to execute. The sequence of two get operations is likely to be faster than a single query. For example, on the status dashboard, a get operation hovers at around 10 milliseconds, while a query operation hovers at around 80 milliseconds - but if this matters to you, I would encourage you to benchmark both and verify for yourself.
Upvotes: 4
Reputation: 41040
I believe that option 1 will be faster, because in option 2 you perform one operation, get the result, and only after that perform the second operation.
The difference, however, is negligible, unless you do it at least a few million times each day.
Upvotes: 1