objectify query count

673 views
Skip to first unread message

Luke

unread,
Feb 28, 2011, 2:05:42 PM2/28/11
to objectify-appengine
1.when doing query.count(), does objectify retrive all the records
into applicaition or just do direct count in datastore?
2. query.count() return integer not long. will that be problem if
there are "too many" records in datastore?

Jeff Schnitzer

unread,
Feb 28, 2011, 2:22:20 PM2/28/11
to objectify...@googlegroups.com
Query.count() simply calls the low-level api
PreparedQuery.countEntities() method.

* The datastore iterates through the index and counts for you.
* You will not be able to count 4 billion records in the time allowed
to service a request.

If you need realtime counts of large numbers of records, you need to
consider alternative strategies. There is much discussion of this in
the archives of the google appengine mailing list.

Jeff

Luke

unread,
Feb 28, 2011, 9:48:43 PM2/28/11
to objectify-appengine
@Jeff,
do you mean alternative is to use sharded counter for huge records?

Jeff Schnitzer

unread,
Feb 28, 2011, 10:02:08 PM2/28/11
to objectify...@googlegroups.com
That's one option in the category of "update statistics as you go".
The other broad category is "batch calculate statistics at intervals".

Jeff

Reply all
Reply to author
Forward
Message has been deleted
0 new messages