Google App Engine ndb re-ownership performance

Can I pay a penalty for executing the request if I want to request the repeated property? For instance:

 class User(ndb.Model): user_name = ndb.StringProperty() login_providers = ndb.KeyProperty(repeated=true) fbkey = ndb.Key("ProviderId", 1, "ProviderName", "FB") for entry in User.query(User.login_providers == fbkey): # Do something with entry.key 

vs

 class User(ndb.Model) user_name = ndb.StringProperty() class UserProvider(ndb.Model): user_key = ndb.KeyProperty(kind=User) login_provider = ndb.KeyProperty() for entry in UserProvider.query( UserProvider.user_key == auserkey, UserProvider.login_provider == fbkey ): # Do something with entry.user_key 

Based on the documentation from GAE, it seems that Datastore will take care of indexing, and the first less detailed option will use the index. However, I could not find any documentation supporting this.

Edit

The only purpose of UserProvider in the second example is to create a one-to-many relationship between the user and his login_provider. I would like to understand whether it is worth creating a second object instead of a query in the repeated property. Also, suppose that all I need is a key from User .

+4
source share
1 answer

No. But you will increase your recording costs, because each record must be indexed, and the recording costs are based on the number of updated indexes.

+6
source

Source: https://habr.com/ru/post/1489551/


All Articles