0

有没有办法优化这个mysql查询?我在一个表中有大约 100K 行。

select  komentarai.* FROM (
  SELECT MAX(id) AS max_id FROM komentarai WHERE siteid=1 GROUP BY number 
) AS tbl
INNER JOIN `komentarai` ON komentarai.id = tbl.max_id ORDER BY komentarai.added DESC LIMIT XX, 10

下面是索引的解释:

PRIMARY <derived2> ALL NULL NULL NULL NULL 3372 Using temporary; Using filesort
PRIMARY komentarai eq_ref PRIMARY,id PRIMARY 4 tbl.max_id 1 2
DERIVED komentarai ref siteid siteid 1 5695 Using where; Using temporary; Using filesort

谢谢!

4

0 回答 0