What would be the best (i.e. most efficient) way of counting the number of objects returned by a query, w/o actually loading them, using Objectify on AppEngine? I'm guessing the best is to fetch all the keys and counting the result:
public int getEntityCount(Long v) {
Objectify ofy = ObjectifyService.begin();
Iterable<Key<MyEntity>> list = ofy.query(MyEntity.class)
.filter("field", v).fetchKeys();
int n = 0;
for (Key<MyEntity> e : list)
n++;
return n;
}
Doesn't seems to have any dedicated method for doing that. Any ideas?