Is a query on type User more expensive than querying on type Key?

In storing references to users of your application across multiple
Kinds, which is better the better approach assuming I don't need
locking for transactions?

a) store the "User" type (the actual User object) or
b) store a "Key" type (that was used as the Primary Key for a Kind
that stores user information)

For example, if the Kind AppUser is defined as...

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class AppUser {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private User user;
...
}

and we're storing an image uploaded by that AppUser, is it better to
use:

Option (a)

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UploadedImage {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private User user;
...
}

or, Option (b)

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UploadedImage {
        @PrimaryKey
        @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private Key appUserKey;
...
}

When retrieving 100s of images owned by the currentUser(), is option
(b) preferred even though it would require the initial lookup of the
AppUser  before querying UploadedImage using appUserKey?

-- 
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