I just let the datastore do it. I like having Long ids: * Longs always stick out in code as an id - ie in a constructor with 15 things, it sucks when they are all Strings. I often wish Java supported C-style typedefs (or just allowed subclassing basic types).
* Long keys are more efficient, storagewise, in a way that is much more significant than it would be in an RDBMS. This isn't massively compelling but remember how BigTable stores every single piece of data: /appid/kind/key/field/data. This means that large key sizes have the exact same bloating effect that large kind names have. This is really only relevant when you're optimizing entities that have zillions of instances, but it's something to be aware of. * I don't trust UUIDs to be universally unique. If you start reading up on UUIDs, the first thing you'll note is that there are a wide variety of algorithms for generating UUIDs and different approaches (eg, time at beginning vs time at end) *can* generate overlapping ids. So the whole concept is broken from the start. If you ever merge your database with another corporate system, you will still need to deconflict your IDs, so what was the point of this exercise in the first place? * I like "generally increasing integer ids" because at a glance you can tell roughly how old an entity is. This is a negative for some overly-security-conscious people, but it's occasionally mildly convenient for debugging. BTW, you can generate 1000 ids in a single datastore call by calling DatastoreService.allocateIdRange(). Jeff On Mon, Jun 6, 2011 at 2:42 AM, Drew Spencer <[email protected]> wrote: > Thanks Remy, > I've just had a little play about with the java.util.UUID class. Seems > pretty straightforward. I'll have a look into it a bit more later on, but > maybe it will be overkill for my app - it's only a company internal one so > maybe passing so many characters around might slow my app a bit too much. > Any ideas what the difference in overhead on retrieving 1000 UUIDs compared > to 1000 Longs would be? > Jeff, what do you use, and is there any best fit for objectify? I definitely > like the idea of manually assigning my keys rather than letting the > datastore do it. > Drew > > -- > You received this message because you are subscribed to the Google Groups > "Google App Engine for Java" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/google-appengine-java/-/cnJFTlk5X0lHN0lK. > 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. > -- 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.
