Reputation: 956
I have made a registration form for a blog I made using Google Datastore, and now I an trying to make it better.
First thing I seen that can be changed is the way that web application looks for the username in the data store, to see is the username already used.
I did it this way:
db.GqlQuery("SELECT * FROM UserData where username = :1", username)
Can you please refer me to better solution, which will be faster.
Thank you.
Upvotes: 3
Views: 1334
Reputation: 15143
If the usernames are unique, then you can make the username the key, in which you can use a db.Model.get_by_key_name()
Actually, for even better performance, use ndb, which caches your entities for get requests, so it'll be even faster.
Upvotes: 5