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