国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 數(shù)據(jù)庫(kù) > MySQL > 正文

MySQL Index Condition Pushdown(ICP)性能優(yōu)化方法實(shí)例

2024-07-24 12:45:57
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

一 概念介紹

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ù),提高查詢(xún)語(yǔ)句性能。

二 原理

Index Condition Pushdown is not used:

  1 Get the next row, first by reading the index tuple, and then by using the index tuple to locate and read the full table row.
  2 Test the part of the WHERE condition that applies to this table. Accept or reject the row based on the test result.
Index Condition Pushdown is used
  1 Get the next row s index tuple (but not the full table row).
  2 Test the part of the WHERE condition that applies to this table and can be checked using only index columns.
    If the condition is not satisfied, proceed to the index tuple for the next row.
  3 If the condition is satisfied, use the index tuple to locate and read the full table row.
  4 est the remaining part of the WHERE condition that applies to this table. Accept or reject the row based on the test result.

三 實(shí)踐案例

a 環(huán)境準(zhǔn)備
   數(shù)據(jù)庫(kù)版本 5.6.16
   關(guān)閉緩存
  

復(fù)制代碼 代碼如下:

     set query_cache_size=0;
     set query_cache_type=OFF;
 

   測(cè)試數(shù)據(jù)下載地址
b 當(dāng)開(kāi)啟ICP時(shí)
復(fù)制代碼 代碼如下:

mysql> SET profiling = 1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> select * from employees where first_name='Anneke' and last_name like '%sig' ;
+--------+------------+------------+-----------+--------+------------+
| emp_no | birth_date | first_name | last_name | gender | hire_date |
+--------+------------+------------+-----------+--------+------------+
| 10006  | 1953-04-20 | Anneke     | Preusig   | F      | 1989-06-02 |
+--------+------------+------------+-----------+--------+------------+
1 row in set (0.00 sec)
mysql> show profiles;
+----------+------------+--------------------------------------------------------------------------------+
| Query_ID | Duration   | Query                                                                          |
+----------+------------+--------------------------------------------------------------------------------+
| 1        | 0.00060275 | select * from employees where first_name='Anneke' and last_name like '%sig'    |
+----------+------------+--------------------------------------------------------------------------------+
3 rows in set, 1 warning (0.00 sec)
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 杭锦后旗| 南丹县| 茂名市| 阜平县| 太仆寺旗| 辛集市| 揭东县| 双鸭山市| 渭源县| 阜康市| 乌苏市| 新丰县| 宝山区| 改则县| 伊通| 洛浦县| 清徐县| 长丰县| 慈利县| 手游| 微博| 乐山市| 收藏| 彰化县| 那曲县| 清远市| 建昌县| 蓬安县| 社会| 邵阳市| 黔江区| 当涂县| 伊春市| 衡东县| 无为县| 图木舒克市| 眉山市| 裕民县| 秀山| 游戏| 分宜县|