Calculating MD5 is very fast in GAE:

from time import time
from hashlib import md5

s = '1'*100
t = time()
for i in xrange(1000000):
md5(s).digest()
print time() - t

result: 1.4655559063


I remember the key name is limited to 500 bytes long, so it may exceed if
you combine several keys into one.

----------
keakon

My blog(Chinese): www.keakon.net
Blog source code: https://bitbucket.org/keakon/doodle/



On Wed, Dec 15, 2010 at 2:43 PM, johnP <j...@thinkwave.com> wrote:

> I need to create a large amount of records which relate three other
> entities.  Just for example, take 100 people; 100 days; and 100
> restaurants.  To create a record for an intersection of a person/day/
> restaurant, it's possible to create keyname of person.key()+day.key()
> +restaurant.key().  And to retrieve records, it's easy to generate a
> list of keys and use a db.get().
>
> In the internet somewhere, I read a comment by Nick Johnson saying
> that long keynames are inefficient, and that it can be a good idea to
> use a MD5 or SHA1 hash function to shorten the key name.  My question
> is, how expensive are the MD5 and SHA1 functions?
>
> For example, if I need to generate 100 keys for each view (e.g. to
> retrieve people who visited 1 restaurant in 1 day, I can generate 100
> keys and db.get() that list) - is it cheaper to use the MD5 hash to
> keep key_names shorter?  Or is the cost of generating the hashes more
> than any savings from shortening the keys?
>
>
>
>
> --
> 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-appeng...@googlegroups.com.
> To unsubscribe from this group, send email to
> google-appengine+unsubscr...@googlegroups.com<google-appengine%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
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-appeng...@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