Okay, so I noticed that it's the following code, and it's only when I
filter on user *end* event:
Chris Withers wrote:
queryset = TicketStatus.objects.filter(active=True)
if user_id:
queryset = queryset.filter(owner=User.objects.get(id=user_id))
queryset = queryset.filter(ticket__event=event)
return list_detail.object_list(
request,
queryset =
queryset.order_by('ticket__number').select_related('Ticket'),
template_name = 'tickets_list.html',
paginate_by = 50,
extra_context = dict(
events = events,
current_event_id = event.id,
users = users,
current_user_id = user_id
)
)
Here I added:
from django.db import connection
for query in connection.queries:
print query['sql']
print query['time']
print
And it shows the culprit:
SELECT COUNT(*) FROM "tracker_ticketstatus" INNER JOIN "tracker_ticket"
ON ("tracker_ticketstatus"."ticket_id" = "tracker_ticket"."id") WHERE
("tracker_ticketstatus"."active" = True AND
"tracker_ticketstatus"."owner_id" = 1 AND "tracker_ticket"."event_id" = 3 )
38.143
Why is this select being executed? Well, how can I find out what code is
causing it?
Also, why is it so slow?
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
--
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-us...@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.