Comments - Why is ORDER BY in a FROM Subquery Ignored?

9 years, 6 months ago roberto spadim

an 'easy' workaround to this, is:

SELECT field1, field2 FROM (
SELECT field1, field2 FROM table1 
ORDER BY field2
LIMIT 18446744073709551615
) alias

this cause the optimizer to create a temporary table, and use filesort to order the query

the limit number is a 64bit unsigned -1 (2^64-1), this is a big number and can work with 99.999% of queries i know

6 years ago Nicolas Tazzaz

@rspadim : Thank you for the workaround but on my biggest table, the time of execution increased since I tried. Do you have another idea ?

2 years, 4 months ago Michael Widenius

Higher execution time is expected if you force an ORDER BY on your biggest table.

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.