当前位置:网站首页>Mysql - - Index
Mysql - - Index
2022-07-03 21:03:00 【Java ne sait pas】
Catalogue des articles
1、Introduction
MySQLLa définition officielle de l'index est la suivante::Index(Index)C'est de l'aide.MySQLStructure des données pour un accès efficace aux données.
Index en petites quantités de données,Pas très utile.,Mais dans le Big Data,,La différence est évidente.
2、Classification des indices
2.1、Index des clés primaires(PRIMARy KEY)
- Identification unique,Clé primaire non répétable,Une table ne peut avoir qu'une seule clé primaire.
2.2、Index unique(UNIQUE KEY)
- Éviter la duplication des données,L'index unique peut être dupliqué,Il peut y avoir plusieurs index uniques dans un tableau
2.3、Index général(KEY/INDEX)
- Par défaut,index,keyMot - clé pour définir
2.4、Index texte complet(FullText)
- Disponible uniquement avec un moteur de base de données spécifique,MySAM
- Données de localisation rapide
3、Index des tests
3.1、Création10010 000 données
CREATE TABLE `app_user` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) DEFAULT'' COMMENT'Surnom de l'utilisateur',
`email` VARCHAR(50) NOT NULL COMMENT'Boîte aux lettres de l'utilisateur',
`phone` VARCHAR(20) DEFAULT'' COMMENT'Numéro de téléphone portable',
`gender` TINYINT(4) UNSIGNED DEFAULT '0'COMMENT 'Sexe(0:Hommes;1:Femme)',
`password` VARCHAR(100) NOT NULL COMMENT 'Mot de passe',
`age` TINYINT(4) DEFAULT'0' COMMENT 'Âge',
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP,
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=utf8 COMMENT = 'appTableau des utilisateurs'
-- Insérer100Données de jeu
DELIMITER $$ -- Vous devez écrire avant d'écrire une fonction,Le logo
CREATE FUNCTION mock_data()
RETURNS INT
BEGIN
DECLARE num INT DEFAULT 1000000;
DECLARE i INT DEFAULT 0;
WHILE i<num DO
INSERT INTO app_user(`name`,`email`,`phone`,`gender`,`password`,`age`)
VALUES(CONCAT('Utilisateurs',i),'[email protected]',CONCAT('15',FLOOR(RAND()*(999999999-100000000)+100000000)),
FLOOR(RAND()*2),UUID(),FLOOR(RAND()*100));
SET i=i+1;
END WHILE;
RETURN i;
END;
SELECT mock_data()
- Demandes de renseignements999999Données:SELECT * FROM app_user WHERE
name
=‘Utilisateurs999999’;
3.2、Ajouter un index
-- id_Nom du tableau_Nom du champ
CREATE INDEX id_app_user_name ON app_user(`name`)
- Demandes de renseignements999999Données:SELECT * FROM app_user WHERE
name
=‘Utilisateurs999999’;
4、Principes d'indexation
- Plus il y a d'index, mieux c'est.
- Ne pas indexer les données fréquemment modifiées
- Les tableaux de petites quantités de données n'ont pas besoin d'être indexés
- Les index sont généralement ajoutés aux champs couramment utilisés pour les requêtes
边栏推荐
- Volley source code analysis
- 一台服务器最大并发 tcp 连接数多少?65535?
- 2022 high voltage electrician examination and high voltage electrician reexamination examination
- 如临现场的视觉感染力,NBA决赛直播还能这样看?
- In 2021, the global foam protection packaging revenue was about $5286.7 million, and it is expected to reach $6615 million in 2028
- Pengcheng cup Web_ WP
- Qualcomm platform WiFi update disconnect end open event
- Hcie security Day12: supplement the concept of packet filtering and security policy
- Advanced collaboration: coroutinecontext
- [gd32l233c-start] 5. FLASH read / write - use internal flash to store data
猜你喜欢
Inventory 2021 | yunyuansheng embracing the road
@Transactional注解失效的场景
SQL injection - Fundamentals of SQL database operation
Study diary: February 14th, 2022
[Yugong series] go teaching course 002 go language environment installation in July 2022
(5) Web security | penetration testing | network security operating system database third-party security, with basic use of nmap and masscan
Redis data migration (II)
Baohong industry | good habits that Internet finance needs to develop
强化学习-学习笔记1 | 基础概念
Software testing skills, JMeter stress testing tutorial, obtaining post request data in x-www-form-urlencoded format (24)
随机推荐
JVM JNI and PVM pybind11 mass data transmission and optimization
Reinforcement learning - learning notes 1 | basic concepts
Pytorch sets the weight and bias of the model to zero
Battle drag method 1: moderately optimistic, build self-confidence (1)
Qualcomm platform WiFi update disconnect end open event
18、 MySQL -- index
MySQL master-slave synchronization principle
Etcd 基于Raft的一致性保证
[secretly kill little buddy pytorch20 days -day02- example of image data modeling process]
CesiumJS 2022^ 源码解读[7] - 3DTiles 的请求、加载处理流程解析
Capturing and sorting out external articles -- autoresponder, composer, statistics [III]
"Designer universe" APEC safety and health +: environmental protection Panda "xiaobaobao" Happy Valentine's Day 2022 | ChinaBrand | Asia Pacific Economic media
上周内容回顾
Interval product of zhinai sauce (prefix product + inverse element)
强化學習-學習筆記1 | 基礎概念
thrift go
Hcie security Day11: preliminarily learn the concepts of firewall dual machine hot standby and vgmp
MySQL dump - exclude some table data - MySQL dump - exclude some table data
Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths
Advanced collaboration: coroutinecontext