For some reason, we’ve been getting a lot of issues with ORDER BY
optimization recently. The fixes have passed Elena Stepanova’s
scrutiny and I’ve pushed them to MariaDB 10.1. Now, MariaDB’s
ORDER BY ... LIMIT optimizer:
- Doesn’t make stupid choices when several multi-part keys and potential range accesses are present (MDEV-6402)
- Always uses “range” and (not full “index” scan) when it switches to an index to satisfy ORDER BY … LIMIT (MDEV-6657)
- Tries hard to be smart and use cost/number of records estimates from other parts of the optimizer (MDEV-6384, MDEV-465, MySQL …