Get by key is ALWAYS faster than a query. The reason is because this is how
things work underneath the hood:

Get by key: We figure out the BigTable key and do a single row get

Query: First, we do an index scan to find the relevant entries. Then, we do
a parallelized get by key.

If you query, you're paying the cost of the index scan unnecessarily. If you
pass a collection of Keys to be fetched they'll be fetched in parallel,
skipping the index scanning step.

On Fri, Sep 17, 2010 at 7:17 AM, megaswin <[email protected]> wrote:

> Hi guys
> I've got a list of id's and have to extract the appropriate objects
> from the datastore. I use JPA, so it's posible to use method
> EntityManager.find(..) :
>
> Key key = KeyFactory.createKey(SomeEntity.class.getSimpleName(),
> someId);
> SomeEntity se = em.find(SomeEntity.class, key);
>
> A number of id's id about 100-200, the whole number of entries in the
> table is also small (several hundreds). The question is - may be
> better to use query instead of find method. I just afraid that each
> find method invocation requires server-datastore communication when
> query requries only one(is it right?). If so how to do this.
> The query em.createQuery("SELECT e FROM SomeEntity e WHERE (id=1 OR
> id=2 OR id=3)");  returns nothing for some reason.
>
> Any thoughts?
> Thanks Maxim
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en.

Reply via email to