Quantcast
Channel: Toad for MySQL
Viewing all articles
Browse latest Browse all 1315

Forum Post: how I can speed up mysql query with group by

$
0
0
I have simple MyISAM table for search, where I indexed  fulltext search ion "search_text"  for search text table structure :     CREATE TABLE IF NOT EXISTS `product_search` (       `dept_id` int(11) unsigned NOT NULL DEFAULT '0',       `product_id` int(11) NOT NULL DEFAULT '0',       `search_text` longtext,       FULLTEXT KEY `search` (`search_text`)     ) ENGINE=MyISAM DEFAULT CHARSET=utf8; Query :     SELECT p.product_id           , p.dept_id      FROM product_search p      WHERE (MATCH(search_text) AGAINST('fathers day') AND 1 )      GROUP BY product_id LIMIT 50 **With group by** it took around **10-12** seconds **Without group by** it took **0.0086** seconds When I have checked the query with explain query explain :     id     select_type   table      type         possible_keys      key     key_len     ref     rows     Extra          1     SIMPLE          p               fulltext     search             search      0                      1         Using where; Using temporary; Using filesort What should I do in this case?

Viewing all articles
Browse latest Browse all 1315

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>