MySQL Forums :: Optimizer & Parser :: Stop using filesort


Advanced Search

Stop using filesort
Posted by: Mark Duffy ()
Date: May 06, 2011 02:14PM

DROP TABLE IF EXISTS `wordpress`.`bb_posts_fulltext_search`;
CREATE TABLE `wordpress`.`bb_posts_fulltext_search` (
`post_id` int(10) unsigned NOT NULL,
`post_text` longtext,
`topic_id` int(10) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`post_id`,`topic_id`) USING BTREE,
FULLTEXT KEY `post_text` (`post_text`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

DROP TABLE IF EXISTS `wordpress`.`bb_topics_fulltext_search`;
CREATE TABLE `wordpress`.`bb_topics_fulltext_search` (
`topic_id` int(11) NOT NULL,
`topic_title` varchar(255) DEFAULT NULL,
`topic_posts` bigint(20) DEFAULT NULL,
`topic_poster_name` varchar(40) DEFAULT NULL,
`topic_last_post_id` bigint(20) DEFAULT NULL,
`forum_id` int(11) DEFAULT NULL,
`parent_group_id` int(11) DEFAULT NULL,
`child_group_id` int(11) DEFAULT NULL,
`topic_last_post_time` datetime DEFAULT NULL,
PRIMARY KEY (`topic_id`),
KEY `topic_last_post_time` (`topic_last_post_time`),
FULLTEXT KEY `topic_title` (`topic_title`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

SELECT
topic_search.topic_id,
topic_search.topic_title,
topic_search.topic_posts,
topic_search.topic_title,
topic_search.topic_poster_name,
topic_search.topic_last_post_id,
topic_search.topic_last_post_time,
MATCH(post_search.post_text,topic_search.topic_title) AGAINST('searchterms' IN BOOLEAN MODE) AS score
FROM bb_posts_fulltext_search post_search
LEFT JOIN bb_topics_fulltext_search topic_search
ON post_search.topic_id = topic_search.topic_id
WHERE MATCH(post_search.post_text,topic_search.topic_title) AGAINST('searchterms' IN BOOLEAN MODE)
GROUP BY topic_search.topic_id
ORDER BY score DESC
LIMIT 0,6

Explain -> https://gist.github.com/959696

Options: ReplyQuote


Subject Views Written By Posted
Stop using filesort 4529 Mark Duffy 05/06/2011 02:14PM
Re: Stop using filesort 1988 Jørgen Løland 05/08/2011 01:28PM
Re: Stop using filesort 1362 Mark Duffy 05/09/2011 10:57AM
Re: Stop using filesort 3023 Jørgen Løland 05/10/2011 04:40AM
Re: Stop using filesort 1326 Mark Duffy 05/10/2011 11:41AM
Re: Stop using filesort 1957 Jørgen Løland 05/10/2011 12:54PM
Re: Stop using filesort 1349 Mark Duffy 05/12/2011 08:04AM
Re: Stop using filesort 1111 Jørgen Løland 05/12/2011 08:52AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.