小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

將MySQL從5.5升級到5.6后查詢緩慢

 印度阿三17 2019-10-09

我們正在將mysql從5.5升級到5.6,現(xiàn)在某些查詢的速度非常慢.

以前需要0.005秒的查詢現(xiàn)在需要49秒.

對5.6的查詢似乎跳過了索引:

 ---- ------------- ------- ------- ---------------------------------------------------- --------- --------- ------ -------- ------------- 
| id | select_type | table | type  | possible_keys                                      | key     | key_len | ref  | rows   | Extra       |
 ---- ------------- ------- ------- ---------------------------------------------------- --------- --------- ------ -------- ------------- 
|  1 | SIMPLE      | pens  | index | index_contents_on_slug,index_contents_on_slug_hash | PRIMARY | 4       | NULL | 471440 | Using where |
 ---- ------------- ------- ------- ---------------------------------------------------- --------- --------- ------ -------- ------------- 
1 row in set (0.00 sec)

但是在5.5上并沒有被跳過:

 ---- ------------- ------- ------------- ---------------------------------------------------- ---------------------------------------------------- --------- ------ ------ ---------------------------------------------------------------------------------------------- 
| id | select_type | table | type        | possible_keys                                      | key                                                | key_len | ref  | rows | Extra                                                                                        |
 ---- ------------- ------- ------------- ---------------------------------------------------- ---------------------------------------------------- --------- ------ ------ ---------------------------------------------------------------------------------------------- 
|  1 | SIMPLE      | pens  | index_merge | index_contents_on_slug,index_contents_on_slug_hash | index_contents_on_slug_hash,index_contents_on_slug | 768,768 | NULL |    2 | Using union(index_contents_on_slug_hash,index_contents_on_slug); Using where; Using filesort |
 ---- ------------- ------- ------------- ---------------------------------------------------- ---------------------------------------------------- --------- ------ ------ ---------------------------------------------------------------------------------------------- 
1 row in set (0.00 sec)

兩個數(shù)據(jù)庫都是從相同的mysql轉(zhuǎn)儲創(chuàng)建的.

在5.6上進(jìn)行導(dǎo)入時,是否不會構(gòu)建這些索引?如何強(qiáng)制創(chuàng)建索引?

查詢:

SELECT  `pens`.* FROM `pens`  WHERE (slug_hash = 'style' OR slug = 'style') ORDER BY `pens`.`id` DESC LIMIT 1

編輯:刪除架構(gòu)

解決方法:

最終,上面接受的答案是正確的.

@RandomSeed的幫助使我朝著正確的方向思考.基本上,在5.6中創(chuàng)建的優(yōu)化計(jì)劃與在5.5中創(chuàng)建的優(yōu)化計(jì)劃大不相同,因此您可能必須像我一樣對查詢進(jìn)行重新處理.

我沒有最終使用FORCE INDEX,而是刪除了查詢的一部分,直到我確定是什么導(dǎo)致5.6丟失索引.然后,我對應(yīng)用程序邏輯進(jìn)行了重新設(shè)計(jì)以解決該問題.

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多