On Thu, 2008-02-21 at 00:37 -0800, Dave Fowler wrote: > I have a phantom query that is just killing my database. I have a > model named Stats and django is executing the equivalent to > Link.objects.all() in my Stats app. > > # Query_time: 20 Lock_time: 0 Rows_sent: 659528 Rows_examined: 659528 > SELECT > `stats_link`.`id`,`stats_link`.`title`,`stats_link`.`url`,`stats_link`.`last_modified`,`stats_link`.`subdomain_id`,`stats_link`.`avg_time`,`stats_link`.`rating`,`stats_link`.`dlevel`,`stats_link`.`visits` > FROM `stats_link`; > > I've combed my code 100 times and cannot find a single place where I > do anything remotely like this. I have almost a 700,000 entries in my > link table and it takes 20 seconds to execute. > > I added the snippet that shows what queries are executed on each page, > but it shows up on none of my pages. I have a large amount of ajax > for my site so its I can't see every function that way. > > Does anyone know of any other tools beside that snippet to view all my > queries and see what function they're coming from?
Modify the execute() method in django.db.backend.utils.CursorDebugWrapper to also log a stack trace each time execute() is called. If you log the query, plus the result of traceback.print_stack() or traceback.extract_stack() to a file you should be able to work out where the call is coming from. Malcolm -- A conclusion is the place where you got tired of thinking. http://www.pointy-stick.com/blog/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" 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/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

