我有以下SQL查询,目前检查636653行,因此需要进行INDEX调整。
SELECT c.*, g.name AS groupname, cc.name, u.name AS editor, f.content_id AS frontpage, s.title AS section_name, v.name AS author
FROM jos_content AS c
LEFT JOIN jos_categories AS cc ON cc.id = c.catid
LEFT JOIN jos_sections AS s ON s.id = c.sectionid
LEFT JOIN jos_groups AS g ON g.id = c.access
LEFT JOIN jos_users AS u ON u.id = c.checked_out
LEFT JOIN jos_users AS v ON v.id = c.created_by
LEFT JOIN jos_content_frontpage AS f ON f.content_id = c.id
WHERE c.state >= 0 AND c.catid = cc.id AND cc.section = s.id AND s.scope = 'content'
ORDER BY s.title, c.catid, cc.ordering, cc.title, c.ordering
LIMIT 30;
# Time: 111006 16:17:48
# Query_time: 2.228918 Lock_time: 0.000156 Rows_sent: 30 Rows_examined: 636653
这些是EXPLAIN返回的查询使用的索引
select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE c range idx_section,idx_state,idx_catid idx_state 1 NULL 636653 Using where; Using temporary; Using filesort
1 SIMPLE cc eq_ref PRIMARY,cat_idx,idx_section PRIMARY 4 borrar.c.catid 1 Using where
1 SIMPLE s eq_ref PRIMARY,idx_scope PRIMARY 4 borrar.c.sectionid 1 Using where
1 SIMPLE g eq_ref PRIMARY PRIMARY 1 borrar.c.access 1
1 SIMPLE u eq_ref PRIMARY PRIMARY 4 borrar.c.checked_out 1
1 SIMPLE v eq_ref PRIMARY PRIMARY 4 borrar.c.created_by 1
1 SIMPLE f eq_ref PRIMARY PRIMARY 4 borrar.c.id 1 Using index
应该添加哪些索引来提高MySQL查询的性能?
非常感谢,