I found out that on recent versions of MySQL (8+), the order can be set if a limit is explicitely provided in the recordset sent to json_arrayagg , otherwise this is not applied at all.