当前位置:网站首页>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';
边栏推荐
- Clickhouse (03) how to install and deploy Clickhouse
- 7-1 linked list is also simple fina
- Simple query cost estimation
- Quickly generate IPA package
- Pytorch yolov5 training custom data
- 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
- Idea configuring NPM startup
- Is it safe for golden sun to open an account? Can I open an account free of 5 in case?
- 彻底理解为什么网络 I/O 会被阻塞?
- Introduction to Resampling
猜你喜欢

Solutions contents have differences only in line separators

深入底层C源码讲透Redis核心设计原理

2022最新中高级Android面试题目,【原理+实战+视频+源码】

Various pits of vs2017 QT

怎么自动安装pythn三方库

FCN: Fully Convolutional Networks for Semantic Segmentation

Let more young people from Hong Kong and Macao know about Nansha's characteristic cultural and creative products! "Nansha kylin" officially appeared

2022最新Android面试笔试,一个安卓程序员的面试心得

vs2017 qt的各种坑

A2L file parsing based on CAN bus (3)
随机推荐
Take a look at semaphore, the current limiting tool provided by JUC
进程间通信(IPC):共享内存
Is it safe to open an account and register stocks for stock speculation? Is there any risk? Is it reliable?
Reading notes of Clickhouse principle analysis and Application Practice (5)
Isprs2022/ cloud detection: cloud detection with boundary nets
Fix vulnerability - mysql, ES
Icml2022 | partial and asymmetric comparative learning of out of distribution detection in long tail recognition
音视频包的pts,dts,duration的由来.
Quickly generate IPA package
快速生成ipa包
rust统计文件中单词出现的次数
C final review
ROS安装报错 sudo: rosdep:找不到命令
7-1 链表也简单fina
Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app
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?
sample_ What is the relationship between rate, sample and duration
达梦数据库udf实现