mysql列偏移_MySQL:如何对待分布偏移的数据
---
作者微信:gp_22389860
---
btr_estimate_n_rows_in_range_low 函數(shù)用于非唯一訪問(wèn)的行數(shù)評(píng)估也就是在執(zhí)行計(jì)劃生成階段會(huì)去訪問(wèn)實(shí)際的數(shù)據(jù),盡可能的得到正確的執(zhí)行計(jì)劃,這個(gè)過(guò)程叫做dive。其和參數(shù)eq_range_index_dive_limit有關(guān),如果參數(shù)設(shè)置1那么將禁用dive功能,使用統(tǒng)計(jì)數(shù)據(jù)進(jìn)行執(zhí)行計(jì)劃的生成。但某些時(shí)候MySQL 5.7根據(jù)統(tǒng)計(jì)數(shù)據(jù)并不能得到正確的執(zhí)行計(jì)劃,因此才有了dive,但是dive會(huì)產(chǎn)生額外的代價(jià),這個(gè)過(guò)程是需要實(shí)際訪問(wèn)數(shù)據(jù)塊的。
常用的比如非唯一索引的數(shù)據(jù)訪問(wèn),還有> set eq_range_index_dive_limit=100;
Query OK, 0 rows affected (0.00 sec)
mysql> desc select * from testdvi3 where sex='M';
+----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
| 1 | SIMPLE | testdvi3 | NULL | ALL | sex | NULL | NULL | NULL | 30 | 96.67 | Using where |
+----+-------------+----------+------------+------+---------------+------+---------+------+------+----------+-------------+
1 row in set, 1 warning (2.74 sec)
mysql> desc select * from testdvi3 where sex='W';
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | testdvi3 | NULL | ref | sex | sex | 9 | const | 1 | 100.00 | NULL |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
1 row in set, 1 warning (2.00 sec)
mysql> set eq_range_index_dive_limit=1;
Query OK, 0 rows affected (0.00 sec)
mysql> desc select * from testdvi3 where sex='W';
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | testdvi3 | NULL | ref | sex | sex | 9 | const | 15 | 100.00 | NULL |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
1 row in set, 1 warning (0.00 sec)
mysql> desc select * from testdvi3 where sex='M';
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
| 1 | SIMPLE | testdvi3 | NULL | ref | sex | sex | 9 | const | 15 | 100.00 | NULL |
+----+-------------+----------+------------+------+---------------+------+---------+-------+------+----------+-------+
```
來(lái)自 “ ITPUB博客 ” ,鏈接:http://blog.itpub.net/7728585/viewspace-2707569/,如需轉(zhuǎn)載,請(qǐng)注明出處,否則將追究法律責(zé)任。
超強(qiáng)干貨來(lái)襲 云風(fēng)專訪:近40年碼齡,通宵達(dá)旦的技術(shù)人生總結(jié)
以上是生活随笔為你收集整理的mysql列偏移_MySQL:如何对待分布偏移的数据的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: c语言 乱码转化为16进制_面向小白的C
- 下一篇: 串口怎样配置才能无论奇偶校验都能正常接收