当前位置:网站首页>MySQL数据库索引教程(超详细)
MySQL数据库索引教程(超详细)
2022-07-05 18:33:00 【InfoQ】
索引初步
缺点
索引结构

实验准备(以下实验都在VMware中进行)
1、新建一个数据库
create database test default character set utf8;
2、新建一个数据表
CREATE TABLE testsql (
id int NOT NULL AUTO_INCREMENT PRIMARY KEY comment '自增主键',
dept tinyint not null comment '部门id',
name varchar(30) comment '用户名称',
create_time datetime not null comment '注册时间',
last_login_time datetime comment '最后登录时间'
) comment '测试表';
3、写入数据
insert into testsql values(1,1,'user_1', '2018-01-01 00:00:00', '2018-03-01 12:00:00');
4、赋值
set @i=1;
5、做一个表的倍数增加(不然几千万的数据写一年都写不完)
insert into testsql(dept, name, create_time, last_login_time)
select left(rand()*10,1) as dept, #随机生成1~10的整数
concat('user_',@i:[email protected]+1), #按序列生成不同的name
date_add(create_time,interval [email protected]*cast(rand()*100 as signed) SECOND), #生成有时间大顺序随机注册时间
date_add(date_add(create_time,interval [email protected]*cast(rand()*100 as signed) SECOND), interval + cast(rand()*1000000 as signed) SECOND) #生成有时间大顺序的随机的最后登录时间
from testsql;
6、查看
select count(*) from testsql;
show variables like "%_buffer%";
7、实验
select COUNT(*) from t where name='user_500000';
8、创建索引




9、实验效果
select COUNT(*) from t where name='user_500000';
边栏推荐
- 技术分享 | 常见接口协议解析
- What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
- The 11th China cloud computing standards and Applications Conference | China cloud data has become the deputy leader unit of the cloud migration special group of the cloud computing standards working
- 英语句式参考
- Powerful tool for collection processing
- Deep copy and shallow copy [interview question 3]
- The 2022 China Xinchuang Ecological Market Research and model selection evaluation report released that Huayun data was selected as the mainstream manufacturer of Xinchuang IT infrastructure!
- Use of websocket tool
- Precautions for RTD temperature measurement of max31865 module
- 怎么自动安装pythn三方库
猜你喜欢

The 10th global Cloud Computing Conference | Huayun data won the "special contribution award for the 10th anniversary of 2013-2022"

LeetCode 6109. 知道秘密的人数

The 11th China cloud computing standards and Applications Conference | cloud computing national standards and white paper series release, and Huayun data fully participated in the preparation

如何获取飞机穿过雷达两端的坐标

buuctf-pwn write-ups (9)

Record eval() and no in pytoch_ grad()

Memory leak of viewpager + recyclerview

2022 latest Android interview written examination, an Android programmer's interview experience

LeetCode 6111. 螺旋矩阵 IV

如何写出好代码 - 防御式编程
随机推荐
小程序 修改样式 ( placeholder、checkbox的样式)
Solutions contents have differences only in line separators
Is it safe for Apple mobile phone to speculate in stocks? Is it a fraud to get new debts?
Take a look at semaphore, the current limiting tool provided by JUC
[use electron to develop desktop on youqilin]
Writing writing writing
About statistical power
2022 latest intermediate and advanced Android interview questions, [principle + practice + Video + source code]
Is it safe to open an account, register and dig money? Is there any risk? Is it reliable?
如何写出好代码 - 防御式编程
About Estimation with Cross-Validation
Oracle日期格式转换 to_date,to_char,to_timetamp 相互转换
Precautions for RTD temperature measurement of max31865 module
2022年阿里Android高级面试题分享,2022阿里手淘Android面试题目
FCN: Fully Convolutional Networks for Semantic Segmentation
What are the cache interfaces of nailing open platform applet API?
sample_rate(采样率),sample(采样),duration(时长)是什么关系
Trust counts the number of occurrences of words in the file
瞅一瞅JUC提供的限流工具Semaphore
一文读懂简单查询代价估算