当前位置:网站首页>MySql - 如何确定一个字段适合构建索引?
MySql - 如何确定一个字段适合构建索引?
2022-07-26 22:39:00 【everyD_struggle】
基数
某个列唯一键的数量叫作基数。某个列唯一键的数量叫作基数。
当查询结果是返回表中5%以内的数据时,应该走索引;当查询结果返回的是超过表中5%的数据时,应该走全表扫描。
选择性
基数与总行数的比值再乘以100%就是某个列的选择性。
当一个列选择性大于20%,说明该列的数据分布就比较均衡了。
当某个列基数很低,该列数据分布就会不均衡。数据分布不均衡会导致在查询该列的时候,要么走全表扫描,要么走索引扫描,这个时候很容易走错执行计划。
回表概念:当对一个列创建索引之后,索引会包含该列的键值以及键值对应行所在的rowid。通过索引中记录的rowid访问表中的数据就叫回表。回表一般是单块读,回表次数太多会严重影响SQL性能,如果回表次数太多,就不应该走索引扫描了,应该直接走全表扫描。
边栏推荐
- Linux系统中安装Redis-7.0.4
- 公司给了IP地址如何使用(详细版)
- js检测屏幕的方法总结 2021-10-05
- 8_ Polynomial regression and model generalization
- C language is more than a variety of descriptions of size. Don't stick to one way of writing
- [qt] solve the problem of Chinese garbled code
- [CTF 真题] 2018-网鼎杯-Web-Unfinish
- Vector size performance problems
- DOM day_02(7.8)网页制作流程、图片src属性、轮播图、自定义属性、标签栏、输入框事件、勾选操作、访问器语法
- Two or three things about redis
猜你喜欢
![[HFCTF2020]EasyLogin](/img/23/91912865a01180ee191a513be22c03.png)
[HFCTF2020]EasyLogin

DOM day_ 01 (7.7) introduction and core operation of DOM

Search engine realizes keyword highlighting
![[qt] container class, iterator, foreach keyword](/img/88/d9d5be096009b4e5baa0966e6f292c.jpg)
[qt] container class, iterator, foreach keyword

公司给了IP地址如何使用(详细版)

5_ Linear regression

10个Web API
Alibaba internal "shutter" core advanced notes~
![[ciscn2019 finals Day2 web1]easyweb](/img/36/1ca4b6cae4e0dda0916b511d4bcd9f.png)
[ciscn2019 finals Day2 web1]easyweb

八皇后 N皇后
随机推荐
DOM day_ 03 (7.11) event bubbling mechanism, event delegation, to-do items, block default events, mouse coordinates, page scrolling events, create DOM elements, DOM encapsulation operations
[BJDCTF2020]EzPHP
CUDA version difference between NVIDIA SMI and nvcc -v
C language shutdown applet
[HITCON 2017]SSRFme
Yolo of Darknet_ Forward of layer_ yolo_ Layer comments
JSCORE day_03(7.4)
CDs simulation of minimum dominating set based on MATLAB
DOM day_ 01 (7.7) introduction and core operation of DOM
[CISCN2019 总决赛 Day2 Web1]Easyweb
JSCORE day_01(6.30) RegExp 、 Function
【4.9 容斥原理详解】
DOM day_ 02 (7.8) web page production process, picture SRC attribute, carousel chart, custom attribute, tab bar, input box event, check operation, accessor syntax
On the expression of thymeleaf
Detailed explanation of CSRF forged user request attack
DOM day_04(7.12)BOM、打开新页面(延迟打开)、地址栏操作、浏览器信息读取、历史操作
Search engine realizes keyword highlighting
【AtCoder Beginner Contest 261 (A·B·C·D)】
[leetcode] no duplicate longest string
MySQL associative table queries (reducing the number of queries)