Let's say we have:
class User(db.Model):
nickname = db.StringProperty()
and we have 500k entities in User, each with a unique nickname.
and I now want to add one more entity, and it must be a unique nickname. So I run this:
to_check = User.gql("WHERE nickname = :1",new_nickname).get()
if to_check is None:
# proceed to create entity
User(nickname=new_nickname).put()
is this method going to work for over 500k users? Am I going to experience slow processing times?
what are the optimization methods for this?
PS: is indexing the nickname property a good way to proceed?
I can only think of this at the moment:
class User(db.Model):
nickname = db.StringProperty(indexed=True) # index this property
EDITED: btw, I have two unique properties I want to maintain: userid and nickname. The userid will be automatically assigned as the keyname ( I'm making a facebook app which takes the user's facebook id and creates a user entity)
So to me, userid is more important so I'll use it as the keyname.
The nickname will be manually entered by the facebook user, so I need a mechanism to check whether it is unique or not.
so the problem now is, what do I do with the nickname? I can't have two keynames :(