计算GQL结果的最佳方式是什么? [英] What's the best way to count results in GQL?

查看:99
本文介绍了计算GQL结果的最佳方式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  foo = db.GqlQuery(SELECT * FROM bar WHERE baz ='baz')
my_count = foo.count()

我不知道我的计数会被限制在1000以内,而且我的查询可能会很慢,任何人都可以使用一种解决方法吗?我有一个想法,但它并不干净,如果只有GQL有一个真正的COUNT函数。 ..


解决方案

+1对于耶和华的回应。在GAE上获取对象计数器的有效方法是构建分片计数器。名字,这非常简单。


I figure one way to do a count is like this:

foo = db.GqlQuery("SELECT * FROM bar WHERE baz = 'baz')
my_count = foo.count()

What I don't like is my count will be limited to 1000 max and my query will probably be slow. Anyone out there with a workaround? I have one in mind, but it doesn't feel clean. If only GQL had a real COUNT Function...

解决方案

+1 to Jehiah's response.

Official and blessed method on getting object counters on GAE is to build sharded counter. Despite heavily sounding name, this is pretty straightforward.

这篇关于计算GQL结果的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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