#33768: MySQL ordering of nulls last/first is broken in combination with UNION
-------------------------------------+-------------------------------------
     Reporter:  Florian Apolloner    |                    Owner:  Aniruddh
                                     |  Singh
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  dev
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Aniruddh, we appreciate your interest but this issue is quite complex so
 you might want to focus on another issue instead for your first
 contributions.
 ----

 Thanks for the great summary Florian!

 > Maybe, in hindsight that would probably should have been the way to
 implement unions (etc) in the first place. Maybe now is the time to switch
 to that :) What does a subquery mean in terms of performance -- I'd hope
 the database wouldn't care to much…

 From some limited local testing on SQLite, PostgreSQL, and MySQL and
 looking at the generate `EXPLAIN` plan it doesn't seem like they care too
 much. But it might not be necessary after some more thoughts as the `ORDER
 BY` clause allows for ordering by aliases as well.

 > Reusing aliases and references seems like a good idea. It makes the
 query imo more readable and also means less parsing overhead for the
 server (probably negligible but still).

 I completely agree with this statement but I don't understand how this
 relates to using selected field indexes instead of aliases?

 From my understanding and testing engines locally it seems that all
 engines allow to refer to the first query member of the union by column
 aliases just like by index so once we've addressed the issue with ordering
 by selected references not being used we could entirely drop the
 specialized combinator logic that uses `RawSQL` to order by column index?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33768#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701817f6f4416-221e0861-520d-442b-962a-395a1a37dc0b-000000%40eu-central-1.amazonses.com.

Reply via email to