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

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

问题描述

IN 查询的文档操作表明这些查询是作为一个大的 OR'ed 等式查询实现的:

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']))

相当于:

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

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

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))

其中 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?

推荐答案

这不适用于数以千计的值(事实上我敢打赌它会在超过 10 个值时开始降级).我能想到的唯一选择是某种形式的预计算.您必须更改架构.

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天全站免登陆