Hi,
Could you explain me with it uses a dic to cach the query :
### GQL query cache ###
_query_cache = {}
and not memcache.
I'd like to have a "caching" best practice : global variable VS
memcache
Thank you
Regards
On 1 oct, 07:25, Bill <[EMAIL PROTECTED]> wrote:
> Try using fetch instead of treating the GqlQuery object as an
> iterable. If you had included a LIMIT or OFFSET clause, it would
> automatically be retrieved by fetch.
> So it would be something like:
>
> users = db.GqlQuery(toquery).fetch(limit=1000)
>
> Seehttp://code.google.com/appengine/docs/datastore/queryclass.html
>
> You can also cache the query like rietveld.
> Seehttp://code.google.com/p/rietveld/source/browse/trunk/codereview/mode...
> and look at the gql method.
>
> On Sep 30, 7:17 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
> > my app is producing significantly high mcycles used results. i have
> > debugged it and determined that the problem is in my for loop. So I
> > tried two versions and both are too slow.
>
> > Version 1:
>
> > somestuff = ['cat', 'dog', 'cow'];
>
> > toquery = "SELECT * FROM Animals Where id IN (" + somestuff + ")"
> > users = db.GqlQuery(toquery)
>
> > now i get a list of users that match that key and I do a for loop like
> > this:
>
> > for user in users:
> > self.response.out.write(user.id)
>
> > Gives me a lot of mcycles with a red hazard warning. If I remove the
> > for loop the hazard goes away. The datastore query takes less then a
> > second.
>
> > VERSION 2
>
> > somestuff = ['cat', 'dog', 'cow'];
>
> > for animal in somestuff:
> > toquery = "SELECT * FROM Moodster Where id = '" + animal + '\''
> > for user in users:
> > self.response.out.write(user.id)
>
> > in the latter version I am doing many queries (in this case 3) but
> > because there is only one user in users for each query (i make sure of
> > this), it takes less mcycles and gets a faster response
>
> > AM I DOING SOMETHING WRONG?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---