python - appengine : NeedIndexError: The built-in indices are not efficient enough for this query and your data. 请为此查询添加复合索引

标签 python django google-app-engine google-cloud-datastore

使用 django.core.paginator import ObjectPaginator 时,出现此错误:

NeedIndexError: The built-in indices are not efficient enough for this query and your data. Please add a composite index for this query.

原始查询是这样写的:

query = models.Cdr.all()
query.filter("var1 =", var1 )
query.filter("var2 =", var2)
query.filter("var3 =", var3)

当 ObjectPaginator 尝试计算元素数量时,我收到此异常,但仅限于 var1 的某些值。

为什么此查询对于 var1 的某些值会失败,而与其他值一起使用?

对于这种情况,您有什么建议?

最佳答案

建议修复 NeedIndexError 出现的一般过程是 this one 。我预计复合索引可能尚未在您的开发中构建,具体取决于数据的数量和结构(可能会根据 var1 值而变化),但事实证明是需要的(以避免中止查询出于效率原因,正如错误消息提示和尼克在此评论中确认的那样)在实际商店上运行时。

关于python - appengine : NeedIndexError: The built-in indices are not efficient enough for this query and your data. 请为此查询添加复合索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1363531/

相关文章:

python - Scrapy xpath 返回表中每一行的结果,而不仅仅是选定的行

python - 将 Django 模型移动到它们自己的文件中

java - 使用谷歌应用引擎时显示迭代错误

python - get_num_instances 引发 InvalidVersionError

python - MySQL 从 Python 插入停止

Python:将一个数组中的字符串与另一个数组中的文本中的子字符串进行匹配

python - scrapy 中的项目 vs 项目加载器

python - Django 模板扩展不调用 CSS

python - 按距离对结果进行排序,并获取它们与查询点之间的距离

python - 如何在appengine python中查询没有祖先的实体