开发者

Google App-Engine Java Group By and Count(*) queries

I am able to insert, filter and order records but can't use a simple count!! I am wondering if there a way to get no of total rows in a table?? Is there a开发者_JAVA百科 way to use GROUP BY in query?


You can see statistics about your data at admin interface or by using DatastoreService, and there you can find total count of rows ("entities of kind").

There no way to use GROUP BY, it's unsupported by Google BigTable. See "Unsupported Features"

Before using storages like this you need to read about NoSQL, and understand how it works, and why there can't be group_by, join, etc.


The simplest way is to use cursors to iterate over all records that match the query and count them, but this will give you a big overhead if you have many entities. The smarter way is if you don`t have too complicated filter to use sharded counters to count the results of every possible filter, this also will bring you a headache if you have too much options in the filter. Why is so important to show the number of the user which bring me to the old joke:

Q: How to count 8 millions rows? A: Why/Who need to know that there are 8M rows?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜