views:

132

answers:

2

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?

+4  A: 

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.

splix
Thanks, at present i use statistics to know the no of records. But limitations is it is updated once in a day. Also i want to show it to user on the jsp page.
Manjoor
Then you have to count them by yourself, for example using "sharding counters" pattern: http://code.google.com/intl/en/appengine/articles/sharding_counters.html
splix
OK, that is very simple... But what i need is when user filter records based on some crietria, the page should tell user how many rows are returned by the query..I am creating pages of 100 records. Just wanna show that page X of N.
Manjoor
I don't know any way do do this. At least for any not predefined query. But if know all possible filters you can precalculate count of results for them, using counters, for example.
splix
A: 

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?

Ilian Iliev