使用 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/