国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 加查县| 汤阴县| 承德市| 辽阳县| 灵石县| 丹凤县| 滦南县| 信阳市| 晴隆县| 昭觉县| 贵德县| 麻江县| 连平县| 图木舒克市| 武宁县| 韶关市| 阿尔山市| 敦化市| 哈尔滨市| 出国| 年辖:市辖区| 平阴县| 青田县| 原阳县| 社会| 婺源县| 丰都县| 四子王旗| 封开县| 阳山县| 绍兴县| 奈曼旗| 贡山| 眉山市| 卫辉市| 周至县| 长治县| 丹江口市| 工布江达县| 柳河县| 砀山县|