[google-appengine] Re: What's the difference among key, id, and key name?
Hi Oliver, Doing a get() for a specific key is definitely much faster than doing a query, even if that query only returns one entity. As an example, take a look at the System Status page for gets: http://code.google.com/status/appengine/detail/datastore/2009/05/26#ae-trust-detail-datastore-get-latency and the one for queries: http://code.google.com/status/appengine/detail/datastore/2009/05/26#ae-trust-detail-datastore-query-latency . Gets average 20-40ms, while queries average 150-200ms. -Nick Johnson On Fri, May 22, 2009 at 10:51 AM, Oliver Zheng goo...@oliverzheng.com wrote: Hi Jason, On May 12, 5:12 pm, Jason (Google) apija...@google.com wrote: [...] thereby improving the performance of your application [...] What is the extent of this? I suppose you mean that if you know the key, you can construct an object and save it to datastore by overwriting it, without first querying for that object. But beyond that, is there performance improvement to querying with a key instead of another field that is also indexed? Thanks, Oliver --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
Hi Jason, On May 12, 5:12 pm, Jason (Google) apija...@google.com wrote: [...] thereby improving the performance of your application [...] What is the extent of this? I suppose you mean that if you know the key, you can construct an object and save it to datastore by overwriting it, without first querying for that object. But beyond that, is there performance improvement to querying with a key instead of another field that is also indexed? Thanks, Oliver --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
Yes. See the Model functions that are available: http://code.google.com/appengine/docs/python/datastore/modelclass.html#Model_get_by_key_name http://code.google.com/appengine/docs/java/javadoc/com/google/appengine/api/datastore/DatastoreService.html - Jason On Wed, May 13, 2009 at 4:47 AM, Big Stu stu.dohe...@gmail.com wrote: When you create entities, you have the option of specifying a unique key name that you can use to reference these entities directly (e.g. retrieving entities without queries, thereby improving the performance of your application). I'm not sure what you mean by this. Are you saying if I know enough to reconstruct the full key name of an instance I want to retrieve I can instantiate the model with that key name and then start using it directly? In other words, I know that when I create these instances I use some_string + owner model name + something else as the key name, so if I'm in some other situation where I know all those values I can easily rebuild the key name and start using the model without having to run a query on the datastore? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
When you create entities, you have the option of specifying a unique key name that you can use to reference these entities directly (e.g. retrieving entities without queries, thereby improving the performance of your application). I'm not sure what you mean by this. Are you saying if I know enough to reconstruct the full key name of an instance I want to retrieve I can instantiate the model with that key name and then start using it directly? In other words, I know that when I create these instances I use some_string + owner model name + something else as the key name, so if I'm in some other situation where I know all those values I can easily rebuild the key name and start using the model without having to run a query on the datastore? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
On Wed, May 13, 2009 at 12:47 PM, Big Stu stu.dohe...@gmail.com wrote: When you create entities, you have the option of specifying a unique key name that you can use to reference these entities directly (e.g. retrieving entities without queries, thereby improving the performance of your application). I'm not sure what you mean by this. Are you saying if I know enough to reconstruct the full key name of an instance I want to retrieve I can instantiate the model with that key name and then start using it directly? In other words, I know that when I create these instances I use some_string + owner model name + something else as the key name, so if I'm in some other situation where I know all those values I can easily rebuild the key name and start using the model without having to run a query on the datastore? That's correct, as long as you also know the entity type and any ancestors' keys. -Nick Johnson --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
On May 12, 11:58 am, Oliver Zheng goo...@oliverzheng.com wrote: I have been looking at the stored data of some apps, and noticed those 3 columns. Key appears to be a hash/string of some sort. ID is usually empty. Key name looks like an actual readable identifier, but it's usually just key_ + username or something that already exists. What is the use for any of this, from the perspective of a (python) app? Why are they created and what can or should I do with them? http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html#Kinds_Names_and_IDs --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[google-appengine] Re: What's the difference among key, id, and key name?
Hi Oliver. This page may help explain the difference between these fields: http://code.google.com/appengine/docs/python/datastore/keysandentitygroups.html When you create entities, you have the option of specifying a unique key name that you can use to reference these entities directly (e.g. retrieving entities without queries, thereby improving the performance of your application). If you don't pass in a key name, a unique ID will be created for you, which is contained in the ID field. The key field is a Base64 encoding of the full key, including application ID and path. This is what is stored when you use reference properties for example. - Jason On Mon, May 11, 2009 at 4:52 PM, Oliver Zheng goo...@oliverzheng.comwrote: I have been looking at the stored data of some apps, and noticed those 3 columns. Key appears to be a hash/string of some sort. ID is usually empty. Key name looks like an actual readable identifier, but it's usually just key_ + username or something that already exists. What is the use for any of this, from the perspective of a (python) app? Why are they created and what can or should I do with them? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---