Hi,
I was having trouble as well with retrieving data quickly and not sure
of the best approach. I currently have my JDO object (JdoEvent) on the
client (and was advised recently that this may not be the best place
to put it) and was retrieving about a 1000 objects and this was taking
longer than I'd like. My approach follows and I welcome any criticisms
of it, thank you
public List<JdoEvent> getEvents() {
return get(JdoEvent.class, "order by date desc");
}
private <T> List<T> get(Class<T> cls, String filterClause) {
PersistenceManager pm = PMF.get().getPersistenceManager();
List<T> result = null;
try {
String q = "select from " + cls.getName() + " " +
filterClause;
result = new ArrayList<T>((List<T>)
pm.newQuery(q).execute());
} finally {
pm.close();
}
return result;
}
On Feb 23, 3:35 am, John Patterson <[email protected]> wrote:
> You can set the chunk size to 100 or use one of the non iterator query
> methods. By default only 20 results are loaded at a time so for 100
> results the iterator does 5 queries.
>
> On 22 Feb 2010, at 02:23, Ftaylor wrote:
>
> > 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]
> > .
> > For more options, visit this group
> > athttp://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.