optimizer_join_limit_pref_ratio Optimization
An optimization that can pick a join order which shortens ORDER BY ... LIMIT queries.
Last updated
Was this helpful?
Was this helpful?
+------+-------------+----------+------+---------------+---------------+---------+---------------+------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+------+---------------+---------------+---------+---------------+------+----------------------------------------------+
| 1 | SIMPLE | customer | ALL | name | NULL | NULL | NULL | 9623 | Using where; Using temporary; Using filesort |
| 1 | SIMPLE | orders | ref | customer_name | customer_name | 103 | customer.name | 1 | |
+------+-------------+----------+------+---------------+---------------+---------+---------------+------+----------------------------------------------++------+-------------+----------+-------+---------------+------------+---------+----------------------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+------+-------------+----------+-------+---------------+------------+---------+----------------------+------+-------------+
| 1 | SIMPLE | orders | index | customer_name | order_date | 4 | NULL | 10 | Using where |
| 1 | SIMPLE | customer | ref | name | name | 103 | orders.customer_name | 1 | |
+------+-------------+----------+-------+---------------+------------+---------+----------------------+------+-------------+SELECT *
FROM
customer,ORDER
WHERE
customer.name=ORDER.customer_name
AND ORDER.shipping_method='Airplane'
ORDER BY
ORDER.DATE DESC
LIMIT 10order.shipping_method='%Airplane%'Do consider the query plan using LIMIT short-cutting
and prefer it if it promises at least X times speedup.