Doing a global count of an object type (like Users), best practice?
Posted
by user246114
on Stack Overflow
See other posts from Stack Overflow
or by user246114
Published on 2010-04-21T14:31:43Z
Indexed on
2010/04/21
14:33 UTC
Read the original article
Hit count: 146
google-app-engine
Hi,
I know keeping global counters is frowned upon in app engine. I am interested in getting some stats though, like once every 24 hours. For example, I'd like to count the number of User objects in the system once every 24 hours.
So how do we do this? Do we simply keep a set of admin tool functions which do something like:
SELECT FROM com.me.project.server.User;
and just see what the size of the returned List is? This is kind of a bummer because the datastore would have to deserialize every single User instance to create the returned list, right?
I could optimize this possibly by asking for only the keys to be returned, so the whole User object doesn't have to be deserialized.
Then again, a global counter for # of users probably would create too much contention, because there probably won't be hundreds of signups a minute for the service I'm creating.
How should we go about doing this? Getting my total number of users once a day is probably a pretty typical operation?
Thank you
© Stack Overflow or respective owner