hi all! there's lots of good information in this thread on how to
generate partially and fully unique ids, along with pros and cons. i'm
also curious about the actual use case, though. specifically...

On Nov 22, 6:38 pm, Andy Freeman <ana...@earthlink.net> wrote:
>
> Each db.put has significant overhead.  If I can generate a unique name
> without a db.put, I can reduce the number of db.puts that my
> application does by a factor of 2.
...
> It introduces a clean-up problem.   I can't delete such an object
> until after I delete all entity groups named using said object's key.
> (GAE is free to reused generated keys.)
>
> I shouldn't have mentioned the overhead of puts.  The real problem is
> cleanup and consistency, a problem that transactions are designed to
> solve.

i'm curious how a named key buys you anything here beyond what an id-
based key gives you.

as background, from my perspective, named keys are useful when you
have an external identifier and you want to enforce and exploit
uniqueness in a namespace that you control. they also let you do a
limited form of querying inside transactions, via get() with a key
that you construct in memory. we found this useful enough that we
added get_by_key_name() as syntactic sugar for it.

i suspect most of the use cases for named keys fit into that mold. as
you mentioned, they don't generally help with optimization, since for
a given use case, named keys will require the same number of put()s as
id-based keys. i'm also not sure how they help with cleanup/garbage
collection or consistency. queries and transactions don't
differentiate between root entities with named keys vs. id-based keys.

btw, you probably already know this, but just in case, you can create
a new root entity and one or more children of that entity in the same
transaction. e.g.

def create():
  parent = Foo()
  parent.put()
  child = Foo(parent=parent)
  child.put()
  return parent

parent = run_in_transaction(create)

i'm still curious, so i'm probably missing something...?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to