I think you should ask yourself what data you need from the user. I know this might not seem like the best way(in a RDBM), but you might want to store the information from the user, in the clip. Especially if it is information that doesn't change very often like user name. That way you have the information each time you load the clip and don't even have to run those expensive queries. The added work is that when a user changes their user name, you need to update a bunch of records, but you can do that in a task queue and it probably doesn't happen nearly as often as looking at a list of clips does .
On Feb 11, 1:48 pm, Tony Chuinard <tony.chuin...@gmail.com> wrote: > My project consists of thousands of audio clips, each submitted by a user > (kind of like YouTube). > > Currently, the Clip entity is as follows > > // .... > private long userId; > > So userId is the id of the person who made that clip. Since I want to load > the User object when I load a record, I take my list of recordings (never > above 20) and do something like this: > > SELECT FROM User s WHERE s.id = userIdOfFirst OR s.id = userIdOfSecond > OR..... > > This works, and I create a Map<Long, User> which now allows me to lookup > users by ID in my app when displaying data to the user, but is this the most > efficient way of doing it? I was looking at storing a private Key user, > because I know I can't do private User user, but I don't know if replacing > it with Keys would be a lot more efficient since that long is just a key. > > So does that big OR query have any performance implications? Would I be > better off doing something like: > List<User> relevantUsers = new LinkedList<User>(); > for (Clip clip : allMyClips) { > relevantUsers.add(em.load(clip.getUserId())); > > } > > Using the em.load should be really quick because right now the long IS the > key. > > Can someone just fill in these gaps for me on my confusion? -- 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 google-appengine-java@googlegroups.com. To unsubscribe from this group, send email to google-appengine-java+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-appengine-java?hl=en.