Ich habe folgende MySQL-Abfrage:MySQL: ORDER BY-Klausel verlangsamt MATCH AGAINST Suche nach unten
$sql = "SELECT (SELECT COUNT(share_id) FROM pd_shares WHERE section = 'news' AND item_id = news.article_id) AS count_shares, article_id, link, title, publish_date, description, source FROM pd_news AS news WHERE (MATCH (title_ascii, description_ascii) AGAINST ('".match_against($_GET["sn"])."' IN BOOLEAN MODE)) AND article_id > " . $last_index . " ORDER BY article_id ASC LIMIT 0,$limit";
Wenn ich eine Suche, die Abfrage Lasten 513,24 ms mit der ORDER BY-Klausel. Wenn ich es entferne, läuft es 77,12 ms.
Sowohl title_ascii
als auch description_ascii
sind FULLTEXT.
Wie kann ich diese Abfrage neu schreiben, so dass die Laufgeschwindigkeit viel schneller lädt, als es derzeit ist?
Ausgabe von EXPLAIN:
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY news fulltext PRIMARY,news_search news_search 0 NULL 1 Using where; Using filesort
2 DEPENDENT SUBQUERY pd_shares ref section section 19 const,my_database.news.article_id 2 Using index condition
Können Sie Ihre EXPLAIN-Ausgabe posten? –
EXPLAIN Posted. –
Ihre EXPLAIN-Ausgabe sagte uns, dass die Abfrage ziemlich schnell sein sollte, da sie nur wenige Zeilen verarbeitet. Rufen Sie EXPLAIN für den aktuellen Datensatz auf? –