﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28561	Docs inaccurate about QuerySet.order_by('foo__id') creating a join	Marten Kenbeek	nobody	"The documentation on `order_by()` states:

> It is also possible to order a queryset by a related field, without incurring the cost of a JOIN, by referring to the _id of the related field:
> {{{
> # No Join
> Entry.objects.order_by('blog_id')
> 
> # Join
> Entry.objects.order_by('blog__id')
> }}}

([https://docs.djangoproject.com/en/1.11/ref/models/querysets/#order-by link])

However, in recent versions the latter query is optimised and won't create a join:

{{{
>>> print(Bar.objects.order_by('foo__id').query)
SELECT ""foo_bar"".""id"", ""foo_bar"".""foo_id"" FROM ""foo_bar"" ORDER BY ""foo_bar"".""foo_id"" ASC
}}}"	Cleanup/optimization	closed	Documentation	1.11	Normal	fixed			Accepted	1	0	0	0	1	0
