Hi guys, I wanted to talk about the ticket https://code.djangoproject.com/ticket/7231 in the django-dev forum, but my contribution was just deleted, so I'm posting it here to at least get a chance for a discussion.
One argument of the core devs in the ticket is that extra is a bad thing to have, only there because it was there before raw() came. I think that this is wrong, for example when you want to have all the power of the filters and the sortings but still be able to make complex queries that the ORM can't handle in a decent time. And I think that the ability to add join to extra would be a great plus. For example in the admin, you may want to display the number of foreign keys for each row, and eventually, two different counts. Two counts as annotate returns wrong results, where as the possibility to add something like the following resolves the problem and reduces dramatically the query time (by factor 120 in my case). LEFT OUTER JOIN (SELECT COUNT(*) AS "devices_count", "accounts_venuedevice"."venue_id" FROM "accounts_venuedevice" WHERE "accounts_venuedevice"."enabled"=true GROUP BY "accounts_venuedevice"."venue_id" ) AS "enabled_devices" ON ( "accounts_venue"."id" = "enabled_devices"."venue_id") On the other hand, having to add the filters and the sorting by hand to the RawQuerySet is a pain in the ass. Even if extra joins shouldn't be used for production code, it could be very helpful for some edge-cases like for the admin interface. Best, Matthieu -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f15e3c9a-6810-44fb-928d-75f31fc4f87f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.