What is the datastore charges for db.GqlQuery under new pricing scheme?

19 views
Skip to first unread message

Ram Shanker

unread,
Oct 25, 2011, 11:22:38 AM10/25/11
to google-a...@googlegroups.com
As I understand, query result are fetched in batches so even if we process only couple of entities from a query, does it charge for the complete batch operation ??

What is the datastore-read-count if i call query_object.get(), which returns me just the 1st entity ?


It is not exactly clear about Query calls on this page.

Guido van Rossum

unread,
Oct 25, 2011, 5:57:49 PM10/25/11
to Google App Engine

When you call get() on a query, the batch size is set to 1, so no
worries. Similar if you do query_object.fetch(N) -- the batch size is
adjusted to avoid fetching more than N objects.

The only time where you would be fetching unneeded options is if you
use a for-loop over the query and then break. E.g. the following is a
bad way to fetch the first 3 hits:

# Don't do this!
hits = []
for entity in query_object:
if len(hits) >= 3:
break
hits.append(entity)
# Don't do this!

--Guido van Rossum

Reply all
Reply to author
Forward
0 new messages