Newbie Question about Datastore Management

2 views
Skip to first unread message

ERA

unread,
Aug 31, 2008, 12:54:54 AM8/31/08
to Google App Engine
1) How can I find out the TOTAL number of entities in my Model
datastore?

I tried

GQLQuery("SELECT * FROM Document").count()

but this just caps out at a 1000.

There MUST be some way of finding out, right? or do I have to do this
the old fashioned way, and PAGE thru using Offset?

2) is there a way to clear the datastore (rather than do the Horrible
hack of having a batch delete page...).

3) Currently my way of loading data seems to top out at about 20 x 200
x 4 bytes at a time - Does the bulkloader code suffer from these
restrictions? I'm basically oading objects that have a List of 200
integers (thats all they are).

Cheers,
ERA

Alexander Kojevnikov

unread,
Sep 1, 2008, 10:35:58 PM9/1/08
to Google App Engine
> 1) How can I find out the TOTAL number of entities in my Model
> datastore?
>
> I tried
>
> GQLQuery("SELECT * FROM Document").count()
>
> but this just caps out at a 1000.

This is by design. You need to use a counter and update it each time
you add/delete an entity. An efficient implementation is explained in
this Google IO session:
http://sites.google.com/site/io/building-scalable-web-applications-with-google-app-engine

Or just search for "sharded counter".

> There MUST be some way of finding out, right? or do I have to do this
> the old fashioned way, and PAGE thru using Offset?

You cannot offset beyond 1000 entities. When you call fetch() with an
offset parameter, GAE reads all entities that match your query (and
applies the 1000 records limit) then uses the offset. Please read the
documentation on Query.fetch(), it explains this much better:
http://code.google.com/appengine/docs/datastore/queryclass.html#Query_fetch
Reply all
Reply to author
Forward
0 new messages