That being said, your point is still valid. Just in this case the heavy data is accessed "rarely". - ryan.
On Wed, Oct 14, 2009 at 9:27 AM, Andy Freeman <ana...@earthlink.net> wrote: > > > > So now I am thinking of breaking up the WriteUps class into several > > > classes, putting all the lightweight data that I need to access > > > frequently in one class and all the heavy data that I rarely need to > > > access in another and using ancestor relationships and transactions to > > > make sure everything stays together. > > > Does this make any sense, or I am fundamentally misunderstanding how > > > app engine fetches data? > > > > Yes, that sounds like a good idea. > > Where's the tradeoff point? > > For example, suppose that the heavy data is accessed 90% of the time, > but all of the accesses are via a single db.get and the heavy data > instance is always in the same entity group. ("via a single db.get" > means that if the heavy data is in a separate instance and it's > needed, the same db.get is used for both the light data and the heavy > data instances). > > > On Oct 13, 3:49 am, "Nick Johnson (Google)" <nick.john...@google.com> > wrote: > > Hi Shailen, > > > > > > > > > > > > On Sun, Oct 11, 2009 at 4:09 PM, Shailen <shailen.t...@gmail.com> wrote: > > > > > Consider 2 classes: > > > > > class Light(db.Model): > > > location = db.StringProperty() > > > > > class Heavy(db.Model): > > > location = db.StringProperty() > > > content = db.TextProperty() > > > image1 = db.BlobProperty() > > > image2 = db.BLobProperty() > > > image3 = db.BlobProperty() > > > ..., etc., etc. ... > > > > > I have 2 choices when getting information from the datastore: I can > > > either fetch just the keys, or I can > > > fetch the entities themselves. There isn't any way to fetch only a > > > part of an entity (say just the location property in entities of type > > > Heavy). Assuming this is correct, I have a couple of questions: > > > > > 1) If I want to access the location property in both Light and Heavy, > > > is it fair to assume that accessing Light will be speedier than > > > accessing Heavy, since Heavy has to fetch all sorts of data that I > > > don't need but that is part of the entity? > > > > Yes. > > > > > > > > > 2) Would it make sense to break down Heavy into more lightweight > > > classes for more efficient lookup? > > > > In the example above, definitely, yes. > > > > > > > > > This question is probably best clarified by discussing what's > > > happening in my actual application where I allow an Author to create > > > several WriteUps. The WriteUps have numerous properties: a heading, a > > > sub-heading, a lot of text and, optionally, several images, and a few > > > more properties. When displaying the contents of a WriteUp, I need to > > > access all these properties. But sometimes, I need to access only 1 or > > > 2 lightweight properties; for instance, on a page summarizing the > > > WriteUps done by an author, I need to only list the heading and sub- > > > heading; I do not need to access the text or Blob data. But there is > > > no way to access *just* the heading or sub-heading, right? I end up > > > fetching ALL of the entity, whether I need all of it or not. Is this > > > correct? Or does the datastore have some way of optimizing this? > > > > Entities are always fetched in their entirety. > > > > > > > > > > > > > > > > > Reading the In the documentation (in the Queries and Indexes section), > > > we are told: > > > > > # The query is not executed until results are accessed. > > > results = q.fetch(5) > > > for p in results: > > > print "%s %s, %d inches tall" % (p.first_name, p.last_name, > > > p.height) > > > > > When are results 'accessed', when fetch() is called, or when > > > p.first_name, p._last_name, etc. are used? I am assuming that when > > > fetch(5) is called, all 5 entities (assuming they exist) are fetched, > > > and if the entities contain properties other than first_name, > > > last_name or height, they are loaded up too. Is that correct? > > > > Yes. > > > > > > > > > So now I am thinking of breaking up the WriteUps class into several > > > classes, putting all the lightweight data that I need to access > > > frequently in one class and all the heavy data that I rarely need to > > > access in another and using ancestor relationships and transactions to > > > make sure everything stays together. > > > Does this make any sense, or I am fundamentally misunderstanding how > > > app engine fetches data? > > > > Yes, that sounds like a good idea. > > > > -Nick Johnson > > > > > > > > > - Shailen > > > > -- > > Nick Johnson, Developer Programs Engineer, App Engine > > Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration > Number: > > 368047- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > > - Show quoted text - > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---