当前位置:网站首页>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';
边栏推荐
- 7-1 链表也简单fina
- AI Open2022|基于异质信息网络的推荐系统综述:概念,方法,应用与资源
- rust统计文件中单词出现的次数
- 写作写作写作写作
- Find in MySQL_ in_ Detailed explanation of set() function usage
- Reptile 01 basic principles of reptile
- The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
- 7-1 linked list is also simple fina
- buuctf-pwn write-ups (9)
- ROS安装报错 sudo: rosdep:找不到命令
猜你喜欢

Isprs2022/ cloud detection: cloud detection with boundary nets
![[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD](/img/b8/624799e4bf788e4476b155486f478b.png)
[HCIA cloud] [1] definition of cloud computing, what is cloud computing, architecture and technical description of cloud computing, Huawei cloud computing products, and description of Huawei memory DD

Isprs2020/ cloud detection: transferring deep learning models for cloud detection between landsat-8 and proba-v

Record eval() and no in pytoch_ grad()

Trust counts the number of occurrences of words in the file

蚂蚁集团开源可信隐私计算框架「隐语」:开放、通用

Case sharing | integrated construction of data operation and maintenance in the financial industry

彻底理解为什么网络 I/O 会被阻塞?
![Whether to take a duplicate subset with duplicate elements [how to take a subset? How to remove duplicates?]](/img/b2/d019c3f0b85a6c0d334a092fa6c23c.png)
Whether to take a duplicate subset with duplicate elements [how to take a subset? How to remove duplicates?]

@Extension、@SPI注解原理
随机推荐
Vulnhub's darkhole_ two
What is text mining? "Suggested collection"
Notes on common management commands of openshift
Simple query cost estimation
文章中的逻辑词
New words new words new words new words [2]
Thoroughly understand why network i/o is blocked?
Is it complicated to open an account? Is online account opening safe?
7-2 keep the linked list in order
Isprs2022/ cloud detection: cloud detection with boundary nets
sample_rate(采样率),sample(采样),duration(时长)是什么关系
Rse2020/ cloud detection: accurate cloud detection of high-resolution remote sensing images based on weak supervision and deep learning
[use electron to develop desktop on youqilin]
《ClickHouse原理解析与应用实践》读书笔记(5)
Is it safe for golden sun to open an account? Can I open an account free of 5 in case?
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
jdbc读大量数据导致内存溢出
线性表——抽象数据类型
Copy the linked list with random pointer in the "Li Kou brush question plan"
ROS安装报错 sudo: rosdep:找不到命令