Instead of reference properties, I would look at setting up the
properties of your "complete" model as child entities. That will keep
them all physically sequential on disk (I believe), speeding up reads
and keep things less fragile by allowing transactions.

- Justin

On Sep 11, 11:08 pm, GAEfan <[EMAIL PROTECTED]> wrote:
> OK, I think I have mapped out 10 models, instead of my single model.
> That gives me very little wasted memory when querying the entities for
> each view.
>
> However, I have 2 properties that will be common to all entities
> across the models.  My question concerns optimization...
>
> Would it be better to put these universal properties in every model,
> or put them in their own separate model?
>
> If in every model, that means whenever a property changes, I have to
> write it to 10 different models.  But, a single query gets all the
> needed properties for that view.  If in their own model, I only have
> to write them once, but will add an extra query every time I query any
> of the other models. (2 separate queries needed to get the entity's
> properties)
>
> same properties in 10 models...10 writes to update the data
> properties in their own model... extra (though small; just two
> properties) query (2 queries to get the full entity).
>
> If it matters, the properties are updated about once per week, whereas
> queries happen all day long.
>
> Specifically, Date and SalesVolume will be in every view.  Should they
> be put into every model, or kept in a separate model?  Which is more
> efficient?
>
> And thanks to those of you who have responded.
>
> On Sep 11, 2:30 pm, uprise78 <[EMAIL PROTECTED]> wrote:
>
> > When you do a query on an entity that has a referenceProperty and then
> > pull out the reference property the data store is actually doing
> > another query behind the scenes for you.  Using your model classes as
> > an example:
>
> > class myDate(BaseModel):
> >         Date = db.DateProperty()
>
> > class SalesVolume(BaseModel):
> >         Date =
> > db.ReferenceProperty(myDate,collection_name='sales_ref')
> >         Sales = db.FloatProperty()
>
> > res = myDate.all().filter(...)
>
> > for entity in res:
> >   salesCount = entity.sales_ref.Sales  # this line is performing a
> > data store query to get the Sales parameter
>
> > Although you only did one query explicitly yourself you are actually
> > adding one more for each result that you process.
>
> > As for memory management by setting your query = None, I am not sure
> > how Python will handle that.  Seeing as how your web request is so
> > shortlived (< 4 seconds) I don't think it will have much effect but
> > don't quote me on that as I have no idea how it actually allocates/
> > deallocates memory based on the script.  If you assign any of the
> > entities to a different variable in your 'do stuff' section that
> > setting to None won't do anything for sure as there will still be a
> > retain count (a reference) to the entities that were assigned to a
> > different var.
>
> > On Sep 11, 1:22 pm, GAEfan <[EMAIL PROTECTED]> wrote:
>
> > > Thanks, Mike.  I'm afraid I don't understand your "total number of
> > > looks ups" calculation.
>
> > > What would the query(ies) look like, syntactically?
>
> > > And would those queries eliminate the unwanted ReferenceaProperties?
>
> > > While we are discussing memory, wouldn't it be a good practice to set
> > > the query to None after you're done using it?  Wouldn't that clear out
> > > some memory?
>
> > > e.g.
>
> > > query = myData.all().filter(....).fetch(....)
>
> > > for row in query:
> > >     do stuff
>
> > > query = None
>
> > > newQuery = myOtherData.all().....
>
> > > for row in newQuery:
> > >     Do more stuff
>
> > > newQuery = None
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to