当前位置:网站首页>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
边栏推荐
- 淺析 Ref-NeRF
- Brief analysis of ref nerf
- Advanced collaboration: coroutinecontext
- Study diary: February 14th, 2022
- How to choose cache read / write strategies in different business scenarios?
- How to handle wechat circle of friends marketing activities and share production and release skills
- [secretly kill little buddy pytorch20 days -day02- example of image data modeling process]
- Capture de paquets et tri du contenu externe - - autoresponder, composer, statistiques [3]
- 如临现场的视觉感染力,NBA决赛直播还能这样看?
- Analyse de REF nerf
猜你喜欢
《ActBERT》百度&悉尼科技大学提出ActBERT,学习全局局部视频文本表示,在五个视频-文本任务中有效!...
From the behind the scenes arena of the ice and snow event, see how digital builders can ensure large-scale events
"Designer universe" argument: Data Optimization in the design field ultimately falls on cost, safety and health | chinabrand.com org
It is discussed that the success of Vit lies not in attention. Shiftvit uses the precision of swing transformer to outperform the speed of RESNET
强化學習-學習筆記1 | 基礎概念
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks
Capture de paquets et tri du contenu externe - - autoresponder, composer, statistiques [3]
"Designer universe" APEC safety and health +: environmental protection Panda "xiaobaobao" Happy Valentine's Day 2022 | ChinaBrand | Asia Pacific Economic media
Memory analyzer (MAT)
Inventory 2021 | yunyuansheng embracing the road
随机推荐
Volley source code analysis
Compilation Principle -- syntax analysis
Link aggregation based on team mechanism
同花顺开户注册安全靠谱吗?有没有风险的?
JVM JNI and PVM pybind11 mass data transmission and optimization
Etcd 基于Raft的一致性保证
浅析 Ref-NeRF
For in, foreach, for of
9 pyqt5 qscrollarea scroll area and qscrollbar scroll bar
Design e-commerce seckill system
How to set the system volume programmatically- How to programmatically set the system volume?
"Actbert" Baidu & Sydney University of technology proposed actbert to learn the global and local video text representation, which is effective in five video text tasks
【c】 Digital bomb
Nmap and masscan have their own advantages and disadvantages. The basic commands are often mixed to increase output
MySQL master-slave synchronization principle
Experience summary of database storage selection
如临现场的视觉感染力,NBA决赛直播还能这样看?
Custom view incomplete to be continued
How to choose cache read / write strategies in different business scenarios?
Haven't expressed the artifact yet? Valentine's Day is coming. Please send her a special gift~