[MDEV-22807] make NULLS LAST default when sql_mode=ORACLE Created: 2020-06-05 Updated: 2023-11-30 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | New Feature | Priority: | Major |
| Reporter: | Nilnandan Joshi | Assignee: | Ralf Gebhardt |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | Compatibility, Oracle | ||
| Description |
|
In MySQL/MariaDB NULL values are considered lower than any non-NULL
Can we implement something like NULLS LAST so even if with order by esc, NULLs come last and not first? Though for now there is some workaround like using order by with null.
|
| Comments |
| Comment by Alexander Barkov [ 2020-06-05 ] | |||||||
|
This is the relevant SQL standard grammar:
| |||||||
| Comment by Julien Fritsch [ 2020-06-05 ] | |||||||
|
niljoshi nice to have feature request or is there any customer issue request linked to it? | |||||||
| Comment by Sergei Golubchik [ 2020-07-08 ] | |||||||
|
This is just a change in filesort, with NULLS LAST the sorting won't match index order so the optimizer won't be able to use index to resolve the filesort. No changes in storage engines will be needed. As an additional optimization it is possible to use indexes in this case. Instead of index_first and then many times index_next it should start from the first non-null value, iterate till the end, and then start from the beginning to iterate all NULLs. Still doesn't need any changes in engines, all indexes will always stay NULLS FIRST |