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

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

问题描述

我想一种计数的方法是这样的:

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

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

我不喜欢的是我的计数将被限制为最大 1000 并且我的查询可能会很慢.有人有解决方法吗?我有一个,但感觉不干净.要是 GQL 有一个真正的 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 对 Jehiah 的回应.

+1 to Jehiah's response.

在 GAE 上获取对象计数器的官方方法是构建 分片计数器.尽管名字听起来很重,但这很简单.

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