开发者

Google Datastore w/ JDO: Access Times?

开发者 https://www.devze.com 2022-12-27 01:23 出处:网络
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 Lis

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!

0

精彩评论

暂无评论...
验证码 换一张
取 消