Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 way to use GROUP BY in query?

like image 339
Manjoor Avatar asked Sep 17 '26 02:09

Manjoor


2 Answers

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.

like image 126
Igor Artamonov Avatar answered Sep 19 '26 17:09

Igor Artamonov


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?

like image 34
Ilian Iliev Avatar answered Sep 19 '26 15:09

Ilian Iliev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!