Why you interate the results?



2010/2/21 Ftaylor <[email protected]>

> Is this the fastest way to load all of the Elements of a given type
> from the DataStore?
>
> @SuppressWarnings("unchecked")
>        public static final List<Page> loadAllPagesFromDataStore() {
>                List<Page> pages = new ArrayList<Page>();
>                PersistenceManager pm = PMF.get().getPersistenceManager();
>                Query query = null;
>                try {
>                        query = pm.newQuery(Page.class);
>                        List<Page> results = (List<Page>)query.execute();
>                        if(results.iterator().hasNext()) {
>                                Iterator<Page> it = results.iterator();
>                                while(it.hasNext())
>                                        pages.add(pm.detachCopy(it.next()));
>                        }
>                } finally {
>                        query.closeAll();
>                        pm.close();
>                }
>                return pages;
>        }
>
> I ask because the datastore is meant to be very fast at reading huge
> amounts of data, but slow at writing huge amounts of data, yet this
> query is quite slow for only 100 elements.
>
> Thanks,
>
> Finbarr
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine for Java" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine-java%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine-java?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to