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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

MySQL EXPLAIN Extra列的信息

發布時間:2025/6/15 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MySQL EXPLAIN Extra列的信息 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

2019獨角獸企業重金招聘Python工程師標準>>>

MySQL EXPLAIN Extra列的信息

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

Using where

這意味著mysql服務器將在存儲引擎檢索行后再進行過濾。許多where條件里涉及索引中的列,當它如果并且讀取索引時,就能背存儲引擎檢驗,因此不是所有帶有where子句的查詢都會顯示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

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

>?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會對結果使用一個外部索引排序,而不是按照索引次序從表里讀取行。mysql有兩種文件排序算法,兩種方式都可以在內存或磁盤文件上完成。EXPLAIN不會告訴你mysql將使用哪一種文件排序,也不會告訴你排序會在內存里還是磁盤上完成。

>?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

下面的查詢和排序都使用了覆蓋索引,所以不會出現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版本中的新特性,是一種在存儲引擎層使用索引過濾數據的一種優化方式。

a 當關閉ICP時,index 僅僅是data access 的一種訪問方式,存儲引擎通過索引回表獲取的數據會傳遞到MySQL Server層進行where條件過濾。

b 當打開ICP時,如果部分where條件能使用索引中的字段,MySQL Server會把這部分下推到引擎層,可以利用index過濾的where條件在存儲引擎層進行數據過濾,而非將所有通過index access的結果傳遞到MySQL server層進行where過濾。

優化效果:ICP能減少引擎層訪問基表的次數和MySQL Server訪問存儲引擎的次數,減少IO次數,提高查詢語句性能。

>?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對查詢結果排序時會使用一個臨時表。

mysql何時會使用臨時表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)

單獨講

Using join buffer (Batched Key Access)

單獨講

Using MRR

單獨講

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

轉載于:https://my.oschina.net/xinxingegeya/blog/495894

總結

以上是生活随笔為你收集整理的MySQL EXPLAIN Extra列的信息的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。