+----+-------------+-------+--------+---------------+---------+---------+-----------------------+-------+----------------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+-------+--------+---------------+---------+---------+-----------------------+-------+----------------------------------------------+ | 1 | SIMPLE | t | ALL | NULL | NULL | NULL | NULL | 23112 | Using where; Using temporary; Using filesort | | 1 | SIMPLE | m | eq_ref | PRIMARY | PRIMARY | 4 | genteya.t.ID_LAST_MSG | 1 | | +----+-------------+-------+--------+---------------+---------+---------+-----------------------+-------+----------------------------------------------+ 2 rows in set (0.00 sec) mysql> SELECT m.ID_TOPIC FROM yabbse_topics_current AS t JOIN yabbse_messages_current AS m ON (m.ID_MSG=t.ID_LAST_MSG) WHERE t.ID_BOARD=48 ORDER BY m.posterTime DESC LIMIT 1; +----------+ | ID_TOPIC | +----------+ | 87622 | +----------+ 1 row in set (9.58 sec)