views:

72

answers:

1

I am fetching all the instances for a given linkname but I want to call all their values(rating2) to perform a calculation, I debugged and all my time is in the query and fetch lines, I only have a table with 100 items and it is taking 2 seconds!!!!! How can it be this slow to fetch a few items out of a 100 item table and how can I speed this up? I am running this in the command console and calling the appengine_console.py and running my script that way, is it possible that would cause any sort of delay?

class LinkRating2(db.Model):
    user = db.StringProperty()
    link = db.StringProperty()
    rating2 = db.FloatProperty()

def sim_distance(link1,link2,tabl):
    # Get the list of shared_items
    si={}
    query = tabl.all()
    query2 = tabl.all()

    a = query.filter('link = ', link1)
    b = query2.filter('link = ', link2)
    adic ={}
    bdic= {}

    aa = a.fetch(10000)
    bb = b.fetch(10000)

UPDATE/EDIT Hi guys, I put a call to the sim distance function on my main loading page, I am calling sim_distance thousands of times in another function and to my amazement it is taking only 15ms to execute! Here is what I don't understand, why does it take 2 seconds per call when I am running it in the appengine_console.py in the command window? I took an hour to run in the cmd window but instantaneously about when running it from explorer window.

+1  A: 

Have you tried using appstats? That will give you a breakdown on what parts of your page are specifically taking the most time, based on RPC information.

Nick Johnson
I didn't use appstats, but I put in a simple time.time() in two spots and can see the time it takes as I am calling this function, I put them before query and after the fetch in the code above. I'll take a look at appstats and see if I can post a screen shot as well.
Ok, simple question, I followed the appstats page, Can get to it, and if I call the main function will see the get request show up on the page, how go i get it to work with my function above though!? Damn google docs never has any examples of actual usage ever!, I tried including the function in the main, and also tried calling the function as well with the wsgi, any thoughts?
Once AppStats is installed, it should record and present stats for all requests made to the server. I'd expect the request your making to remote_api would show up. Another way to get data: Perhaps you could create a temporary request handler which calls your function. Then browse to the page which causes the server to invoke that request handler. The AppStats data for that request should then reflect the resources consumed by your function.
David Underhill
Yes, I don't understand I just tried inserting this function inside the main function, and then just running the main functionapplication = webapp.WSGIApplication( [('/', MainPage)], debug=True)def main(): run_wsgi_app(application)if __name__ == '__main__': main()but only the get request shows up
I'm sorry, I don't understand what you're saying. What function are you talking about? To install appstats, you need to set up appengine_config.py as it documents, not do anything with a function in your own code.
Nick Johnson
sorry for the delay, yes I followed the directions and have it configured, but what I think I am misintrepreting, is unless the function is called from a page loading (wsig), the appstats will not see the call, so basically I have to have this function being called from the main page or some page I create, I can't just call the function from the command line. I just tried inserting a call to the sim_distance function I want to see in the main page but nothing comes up still all i see is the get request show up.
If you use run_wsgi_app in your app, the appstats middleware will automatically be called.
Nick Johnson