I'm a newbie so I don't know if this would be a good way to do it, but what
about using the extension that sets the parent's key in a field in the child:
@Persistent(defaultFetchGroup = "true")
@Extension(vendorName = "datanucleus", key = "gae.parent-pk", value =
"true")
private Key parentId;
Then your first query is "select parentId from " ...
a.maza wrote:
> hi,
>
> my question refers to the "relation index entities" pattern presented
> by Brett Slatkin at the Google I/O (cf.
> http://code.google.com/events/io/2009/sessions/BuildingScalableComplexApps.html,
> slide 23-28).
>
> I implemented this pattern and the two queries to the datastore work
> really fast. However, I experienced that looping through the index
> entities in order to retrieve the keys of the parents takes about 5
> times longer then a single query to the datastore. The code is quite
> straightforward as you see below:
>
>
> Query q = getPersistenceManager().newQuery("select key from " +
> MessageIndex.class.getName() + " where receiverId == :receiverId");
> List<Key> messageIndexKeys = (List<Key>) q.execute(receiverId);
>
> List<Key> messageKeys = new ArrayList<Key>(messageIndexKeys.size());
> for(Key k : messageIndexKeys) {
> messageKeys.add(k.getParent());
> }
>
> Query q1 = getPersistenceManager().newQuery("select from " +
> Message.class.getName() + " where key == :messageKeys");
> List<Message> messages = (List<Message>)q1.execute(messageKeys);
>
> Is there any possibility to speed up or even avoid the looping to get
> the parent keys? I would envision something like (don't know if it is
> feasible):
>
> Query q1 = getPersistenceManager().newQuery("select from " +
> Message.class.getName() + " where key.child == :messageIndexKeys");
> List<Message> messages = (List<Message>)q1.execute(messageIndexKeys);
>
> thanks and regards,
>
> andr
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---