日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > 数据库 >内容正文

数据库

MySQL EXPLAIN Extra列的信息

發(fā)布時(shí)間:2025/6/15 数据库 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL EXPLAIN Extra列的信息 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

MySQL EXPLAIN Extra列的信息

這一列包含的是不適合在其他列顯示的額外信息。

Using where

這意味著mysql服務(wù)器將在存儲(chǔ)引擎檢索行后再進(jìn)行過(guò)濾。許多where條件里涉及索引中的列,當(dāng)它如果并且讀取索引時(shí),就能背存儲(chǔ)引擎檢驗(yàn),因此不是所有帶有where子句的查詢都會(huì)顯示using where。

>?explain? select?*?from?article?where?createTime?=?'1991-10-10?10:10:10'********************?1.?row?*********************id:?1select_type:?SIMPLEtable:?articletype:?ALL possible_keys:?key:?key_len:?ref:?rows:?5Extra:?Using?where 1?rows?in?set

Using index

這個(gè)值表示mysql將使用覆蓋索引,以避免訪問(wèn)表。不要把覆蓋索引和type:index訪問(wèn)類型混淆了。

>?explain select?title,shortName?from?article********************?1.?row?*********************id:?1select_type:?SIMPLEtable:?articletype:?index possible_keys:?key:?idx_short_name_titlekey_len:?514ref:?rows:?5Extra:?Using?index 1?rows?in?set

Using filesort

這意味著mysql會(huì)對(duì)結(jié)果使用一個(gè)外部索引排序,而不是按照索引次序從表里讀取行。mysql有兩種文件排序算法,兩種方式都可以在內(nèi)存或磁盤文件上完成。EXPLAIN不會(huì)告訴你mysql將使用哪一種文件排序,也不會(huì)告訴你排序會(huì)在內(nèi)存里還是磁盤上完成。

>?explain select?*?from?article?order?by?title,shortName?asc********************?1.?row?*********************id:?1select_type:?SIMPLEtable:?articletype:?ALL possible_keys:?key:?key_len:?ref:?rows:?5Extra:?Using?filesort 1?rows?in?set

下面的查詢和排序都使用了覆蓋索引,所以不會(huì)出現(xiàn)using filesort,

>?explain select?title,shortName?from?article?order?by?title,shortName?asc********************?1.?row?*********************id:?1select_type:?SIMPLEtable:?articletype:?index possible_keys:?key:?idx_short_name_titlekey_len:?514ref:?rows:?5Extra:?Using?index 1?rows?in?set

Using index condition

Index Condition Pushdown (ICP)是MySQL 5.6版本中的新特性,是一種在存儲(chǔ)引擎層使用索引過(guò)濾數(shù)據(jù)的一種優(yōu)化方式。

a 當(dāng)關(guān)閉ICP時(shí),index 僅僅是data access 的一種訪問(wèn)方式,存儲(chǔ)引擎通過(guò)索引回表獲取的數(shù)據(jù)會(huì)傳遞到MySQL Server層進(jìn)行where條件過(guò)濾。

b 當(dāng)打開(kāi)ICP時(shí),如果部分where條件能使用索引中的字段,MySQL Server會(huì)把這部分下推到引擎層,可以利用index過(guò)濾的where條件在存儲(chǔ)引擎層進(jìn)行數(shù)據(jù)過(guò)濾,而非將所有通過(guò)index access的結(jié)果傳遞到MySQL server層進(jìn)行where過(guò)濾。

優(yōu)化效果:ICP能減少引擎層訪問(wèn)基表的次數(shù)和MySQL Server訪問(wèn)存儲(chǔ)引擎的次數(shù),減少IO次數(shù),提高查詢語(yǔ)句性能。

>?explain? select?*?from?article?where?title?=?'hello'?and?shortName?like?'%hello%'********************?1.?row?*********************id:?1select_type:?SIMPLEtable:?articletype:?ref possible_keys:?idx_short_name_titlekey:?idx_short_name_titlekey_len:?257ref:?constrows:?1Extra:?Using?index?condition 1?rows?in?set

Using temporary

這意味著mysql對(duì)查詢結(jié)果排序時(shí)會(huì)使用一個(gè)臨時(shí)表。

mysql何時(shí)會(huì)使用臨時(shí)表https://dev.mysql.com/doc/refman/5.6/en/internal-temporary-tables.html

>?explain? select?id?,?title?from?article?a?where?a.id?=?1?union?select?id?,title?from?article?b?where?b.id?=?2?order?by?id********************?1.?row?*********************id:?1select_type:?PRIMARYtable:?atype:?const possible_keys:?PRIMARYkey:?PRIMARYkey_len:?4ref:?constrows:?1Extra:? ********************?2.?row?*********************id:?2select_type:?UNIONtable:?btype:?const possible_keys:?PRIMARYkey:?PRIMARYkey_len:?4ref:?constrows:?1Extra:? ********************?3.?row?*********************id:?select_type:?UNION?RESULTtable:?<union1,2>type:?ALL possible_keys:?key:?key_len:?ref:?rows:?Extra:?Using?temporary;?Using?filesort 3?rows?in?set

Using join buffer (Block Nested Loop)

單獨(dú)講

Using join buffer (Batched Key Access)

單獨(dú)講

Using MRR

單獨(dú)講

============END============

轉(zhuǎn)載于:https://my.oschina.net/xinxingegeya/blog/495894

總結(jié)

以上是生活随笔為你收集整理的MySQL EXPLAIN Extra列的信息的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。