Google Datastore w/ JDO: Access Times?
I'm hitting what appears (to me) strange behavior when I pull data from the google datastore over JDO. In particular, the query executes quickly (say 100 ms), but finding the size of the resulting List<> takes about one second! Indeed, whatever operation I try to perform on the resulting list takes about a second. Has anybody seen this behavior? Is it expected? Unusual? Any way around it?
PersistenceManager pm = PMF.getPersistenc开发者_运维技巧eManager();
Query q = pm.newQuery("select from " + Person.class.getName());
System.out.println("getting all at " + System.currentTimeMillis());
mcs = (List<Person>) q.execute();
System.out.println("got all at " + System.currentTimeMillis());
int size = mcs.size();
System.out.println("size was " + size + " at " + System.currentTimeMillis());
getting all at 1271549139441 got all at 1271549139578 size was 850 at 1271549141071
-B
Calling execute() executes the query, but doesn't return all the results - results are fetched as-needed when you access the list. Calling .size() requires the datastore to fetch and count all the results, which is a very inefficient operation!
精彩评论