我有这个查询太慢了。这是一个使用 order by 子句从表(包含 1.5m 条记录)中获取所有主题的简单查询。这是查询。请我需要帮助以使此查询快速运行。
SELECT * FROM _sch_forum_topics WHERE _sch_forum_topics.sch_sub_forum_id=4 ORDER BY _sch_forum_topics.topic_last_post_time DESC LIMIT 0,15
<pre>
<h1>schema below</h1>
<pma_xml_export version="1.0" xmlns:pma="http://www.phpmyadmin.net/some_doc_url/">
<!--
- Structure schemas
-->
<pma:structure_schemas>
<pma:database name="ccruize_database" collation="utf8_general_ci" charset="utf8">
<pma:table name="_sch_forum_topics">
CREATE TABLE `_sch_forum_topics` (
`topic_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
`forum_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`sch_sub_forum_id` tinyint(3) unsigned NOT NULL,
`topic_attachment` tinyint(1) unsigned NOT NULL DEFAULT '0',
`topic_approved` tinyint(1) unsigned NOT NULL DEFAULT '1',
`topic_reported` tinyint(1) unsigned NOT NULL DEFAULT '0',
`topic_title` varchar(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`topic_poster` bigint(20) unsigned NOT NULL DEFAULT '0',
`topic_views` mediumint(8) unsigned NOT NULL DEFAULT '0',
`topic_replies` mediumint(8) unsigned NOT NULL DEFAULT '0',
`unit_id` mediumint(8) NOT NULL,
`sch_id` mediumint(8) NOT NULL,
`post_text` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`topic_last_post_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`topic_last_poster_id` mediumint(8) unsigned NOT NULL DEFAULT '0',
`topic_last_poster_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '',
`topic_last_post_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`topic_post_time` datetime NOT NULL,
`post_edit_count` tinyint(1) NOT NULL,
PRIMARY KEY (`topic_id`),
KEY `forum_id` (`forum_id`),
KEY `topic_approved` (`topic_approved`),
KEY `topic_reported` (`topic_reported`),
KEY `unit_id` (`unit_id`),
KEY `sch_id` (`sch_id`),
KEY `topic_post_time` (`topic_post_time`),
KEY `topic` (`topic_poster`,`sch_sub_forum_id`,`topic_last_post_time`)
) ENGINE=InnoDB AUTO_INCREMENT=1277968 DEFAULT CHARSET=utf8;
</pma:table>
</pma:database>
</pma:structure_schemas>
</pma_xml_export>
</pre>