I have the following query which brings back a list of items which fall into a particular category:
SELECT i.id, ir.range_name, it.item_type, i.item_value
FROM items i
LEFT JOIN item_types it ON it.id = i.item_type
LEFT JOIN item_ranges ir ON ir.id = i.item_name
LEFT JOIN menu m ON m.id = it.menu_link
WHERE m.menu_title = 'vehicles'
AND i.item_live = 1
ORDER BY ir.range_name
I was wondering whether the m.menu_title
column needs to be indexed. Currently, there are only about 10 rows in the menu (m) table and this is unlikely to change that much.
However, with the joins, the above query will potentially bring back over 1000000 rows. There are foreign keys on all the joins.
I am trying to avoid filling the database with dummy data to test the query.
EXPLAIN SELECT
. Also, with the proper indexes, it should be no problem to have the database return the results in the desired order. \$\endgroup\$