0

我有一个有很多记录的大类。我必须对其进行排序 topic_lastpost_time

但是当我这样做时,mysql似乎很慢。完成查询我用了 3 秒索引了 topic_lastpost_time 字段

这是示例。我怎样才能加速它?

# Query_time: 3  Lock_time: 0  Rows_sent: 50  Rows_examined: 36075
SELECT   t.topic_id,
         t.m_id,
         t.m_username, 
         t.topic_title,
         t.topic_lastpost_time
FROM     p_topics t
WHERE    t.fc_id = '21'
         AND t.topic_state = '1'
ORDER BY t.topic_type DESC, 
         t.topic_lastpost_time DESC 
LIMIT    0,50;
4

1 回答 1

0

尝试更改 order by 子句的顺序

SELECT   t.topic_id,
     t.m_id,
     t.m_username, 
     t.topic_title,
     t.topic_lastpost_time
FROM     p_topics t
WHERE    t.fc_id = '21'
     AND t.topic_state = '1'
ORDER BY t.topic_lastpost_time DESC  ,
t.topic_type DESC
LIMIT    0,50;
于 2012-04-12T06:09:28.337 回答