Why does this code takes 0.32 CPU hours and has an avreage memory of 24.6 MBytes?
The page refreshes about 30 times until it stops because there are no more datastore entities.
class MainHandler(webapp.RequestHandler):
def get(self):
found = False
q = MyModel.all(keys_only=True).fetch(1000)
if len(q):
self.response.out.write("Deleted %d MyModel entries" % len(q))
found = True
db.delete(q)
q = MyModel2.all(keys_only=True).fetch(1000)
if len(q):
self.response.out.write("Deleted %d MoModel2 entries" % len(q))
found = True
db.delete(q)
if found:
self.response.out.write('<meta http-equiv="Refresh" content="0"/>')
def main():
application = webapp.WSGIApplication([('/', MainHandler)], debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Is there something I can do to speed it up and use less memory?
Thank you
I found out by testing that I can lower the CPU usage by 3 times only by fetching 200 entries at a time:
Fetching 100 results at a time actually is slower than fetching 200 at a time.
But I’ll check into the mapreduce, but I don’t think that this is a thing