Is an NDB membership request (operation "IN") being executed with a large number of possible values?

The documentation for the query operation INstates that these queries are implemented as a large query of OR'ed equality:

qry = Article.query(Article.tags.IN(['python', 'ruby', 'php']))

is equivalent to:

qry = Article.query(ndb.OR(Article.tags == 'python',
                           Article.tags == 'ruby',
                           Article.tags == 'php'))

I am currently modeling some objects for the GAE project and plan to use these membership requests with many possible values:

qry = Player.query(Player.facebook_id.IN(list_of_facebook_ids))

where it list_of_facebook_idscan have thousands of elements.

Will this type of query work with thousands of possible values ​​in a list? If not, what would be the recommended approach for modeling this?

+5
source share
2 answers

( , , 10 ). , , - . .

+8

- FacebookPlayer, . facebook_id. , . :

class FacebookUser(ndb.Model):
    player = ndb.KeyProperty(kind='Player', required=True)

. :

# Build keys from facebook ids.
facebook_id_keys = []
for facebook_id in list_of_facebook_ids:
    facebook_id_keys.append(ndb.Key('FacebookPlayer', facebook_id))

keysOfUsersMatchedByFacebookId = []
for facebook_player in ndb.get_multi(facebook_id_keys):
    if facebook_player:
        keysOfUsersMatchedByFacebookId.append(facebook_player.player)
usersMatchedByFacebookId = ndb.get_multi(keysOfUsersMatchedByFacebookId)

list_of_facebook_ids - , .

0

All Articles