当前位置:网站首页>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
边栏推荐
- Qt6 QML Book/Qt Quick 3D/基础知识
- Wireless network (preprocessing + concurrent search)
- jvm jni 及 pvm pybind11 大批量数据传输及优化
- 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
- JVM JNI and PVM pybind11 mass data transmission and optimization
- Ask and answer: dispel your doubts about the virtual function mechanism
- 如临现场的视觉感染力,NBA决赛直播还能这样看?
- 11-grom-v2-04-advanced query
- The 12th Blue Bridge Cup
- How to set the system volume programmatically- How to programmatically set the system volume?
猜你喜欢

leetcode-540. A single element in an ordered array

Shortest path problem of graph theory (acwing template)
![抓包整理外篇——————autoResponder、composer 、statistics [ 三]](/img/bf/ac3ba04c48e80b2d4f9c13894a4984.png)
抓包整理外篇——————autoResponder、composer 、statistics [ 三]

如临现场的视觉感染力,NBA决赛直播还能这样看?

Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths

强化学习-学习笔记1 | 基础概念

Example of peanut shell inner net penetration

Redis data migration (II)

Gee calculated area

Line segment tree blue book explanation + classic example acwing 1275 Maximum number
随机推荐
University of Electronic Science and technology | playback of clustering experience effectively used in reinforcement learning
Reinforcement learning - learning notes 1 | basic concepts
Nmap and masscan have their own advantages and disadvantages. The basic commands are often mixed to increase output
Install and use Chrony, and then build your own time server
浅议.NET遗留应用改造
Quickly distinguish slices and arrays
淺析 Ref-NeRF
Design e-commerce seckill system
Analyse de REF nerf
Operate BOM objects (key)
Scientific research document management Zotero
Kubernetes 通信异常网络故障 解决思路
Volley source code analysis
Yyds dry goods inventory TCP & UDP
阻塞非阻塞和同步异步的区分 参考一些书籍
Battle drag method 1: moderately optimistic, build self-confidence (1)
[Tang Laoshi] C -- encapsulation: member variables and access modifiers
Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths
LabVIEW training
2022 high voltage electrician examination and high voltage electrician reexamination examination