Re: Count Method Throwing 500 error

18 views
Skip to first unread message

Lokesh Setia

unread,
Sep 15, 2012, 11:43:37 AM9/15/12
to google-a...@googlegroups.com

You are likely running the 60 sec query limit.  Try using cursors (https://developers.google.com/appengine/docs/python/datastore/queryclass#Query_with_cursor) and running the job as a cron or in a backend instance.



On Friday, September 14, 2012 6:17:03 PM UTC+5:30, Naveed Ahmad wrote:

i have got into strenge situation. I want to know count of Fetch based on daily, weekly, monthly and All time. in Datastore, their count is about 2,368,348 whenever i try to get count either by Model or GqlQuery gets 500 error. when rows are less, code below working fine..

can any guru correct me or tell me right solution, please?

please check code below in python...

The Model:

class Fetch(db.Model):
    adid = db.IntegerProperty()
    ip = db.StringProperty()
    date = db.DateProperty(auto_now_add=True)

Stats Codes:

adid = cgi.escape(self.request.get('adid'))
...
query = "SELECT __key__ FROM Fetch WHERE adid = " + adid  + " AND date >= :1"  
rows = db.GqlQuery( query, monthlyDate)
fetch_count = 0
for row in rows:
   fetch_count = fetch_count + 1
self.response.out.write( fetch_count)

thanks, -Navi

Reply all
Reply to author
Forward
0 new messages