NDB成员资格查询(“IN”操作)性能是否降低并具有许多可能的值? [英] Does the NDB membership query ("IN" operation) performance degrade with lots of possible values?

查看:89
本文介绍了NDB成员资格查询(“IN”操作)性能是否降低并具有许多可能的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


<$的文档 c $ c> IN 查询操作表明这些查询是作为一个大OR或相等查询实现的:

   pre> 

相当于:

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

目前,我正在为一个GAE项目建模一些实体,并计划使用这些具有很多可能值的成员查询: $ b

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

其中 list_of_facebook_ids 可能包含数千个项目。



这种类型的查询在列表中的数千个可能的值中表现良好?如果不是的话,建议的方法是什么?解析方案

这不适用于数千个值(事实上我敢打赌,它开始降级超过10个值)。我能想到的唯一选择是某种形式的预计算。你必须改变你的模式。


The documentation for the IN query operation states that those queries are implemented as a big OR'ed equality query:

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 modelling some entities for a GAE project and plan on using these membership queries with a lot of possible values:

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

where list_of_facebook_ids could have thousands of items.

Will this type of query perform well with thousands of possible values in the list? If not, what would be the recommended approach for modelling this?

解决方案

This won't work with thousands of values (in fact I bet it starts degrading with more than 10 values). The only alternative I can think of are some form of precomputation. You'll have to change your schema.

这篇关于NDB成员资格查询(“IN”操作)性能是否降低并具有许多可能的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆