Currently I am keeping an eye on SQL queries by displaying at the
bottom of my base template sql_queries. I'm seeing some queries that
look kind of strange to me, and I was wondering if there was a way to
somehow correlate the queries with my app's Python code.

For example, amongst the SQL queries on one of my pages, I see this
curious pair:

SELECT (1) AS `a` FROM `forums_topic` WHERE `forums_topic`.`id` = 10
UPDATE `forums_topic` SET `forum_id` = 4, `name` = Split Test #1,
`creation_date` = 2009-10-19 21:45:05, `user_id` = 2, `view_count` =
28, `sticky` = False, `locked` = False, `post_count` = 7,
`update_date` = 2009-10-22 20:46:11, `last_post_id` = 34 WHERE
`forums_topic`.`id` = 10

I *think* these two queries are coming from this code:

topic.view_count += 1
topic.save()

but I'm not sure. Is there a debugging technique or tool that could
tell me what line in the user code the SQL came from?

I'm curious what the SELECT (1) is doing and where it came from. Is
Django's ORM checking to see if the topic object exists before
updating it?

Thanks,
BN

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to