当前位置:网站首页>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';
边栏推荐
- Rse2020/ cloud detection: accurate cloud detection of high-resolution remote sensing images based on weak supervision and deep learning
- JDBC reads a large amount of data, resulting in memory overflow
- The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
- Introduction to the development function of Hanlin Youshang system of Hansheng Youpin app
- 写作写作写作写作
- 在通达信上做基金定投安全吗?
- Quickly generate IPA package
- Whether to take a duplicate subset with duplicate elements [how to take a subset? How to remove duplicates?]
- Electron安装问题
- 基于can总线的A2L文件解析(3)
猜你喜欢

《ClickHouse原理解析与应用实践》读书笔记(5)

怎么自动安装pythn三方库

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

Use JMeter to record scripts and debug

@Extension, @spi annotation principle

爬虫01-爬虫基本原理讲解

MYSQL中 find_in_set() 函数用法详解

Rse2020/ cloud detection: accurate cloud detection of high-resolution remote sensing images based on weak supervision and deep learning

Thoroughly understand why network i/o is blocked?

AI open2022 | overview of recommendation systems based on heterogeneous information networks: concepts, methods, applications and resources
随机推荐
达梦数据库udf实现
Trust counts the number of occurrences of words in the file
Insufficient picture data? I made a free image enhancement software
Introduction to Resampling
Oracle日期格式转换 to_date,to_char,to_timetamp 相互转换
How to write good code defensive programming
Case sharing | integrated construction of data operation and maintenance in the financial industry
技术分享 | 接口测试价值与体系
项目中遇到的问题 u-parse 组件渲染问题
Thoroughly understand why network i/o is blocked?
7-2 保持链表有序
2022 latest Android interview written examination, an Android programmer's interview experience
[PM2 details]
Einstein sum einsum
如何获取飞机穿过雷达两端的坐标
Is it safe to open an account and register stocks for stock speculation? Is there any risk? Is it reliable?
Find in MySQL_ in_ Detailed explanation of set() function usage
瞅一瞅JUC提供的限流工具Semaphore
c期末复习
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?