当前位置:网站首页>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
边栏推荐
- Mysql database ----- common commands of database (based on database)
- Sightseeing - statistics of the number of shortest paths + state transfer + secondary small paths
- JVM JNI and PVM pybind11 mass data transmission and optimization
- Set, weakset, map, weakmap in ES6
- 2022 melting welding and thermal cutting examination materials and free melting welding and thermal cutting examination questions
- 你真的知道自己多大了吗?
- XAI+网络安全?布兰登大学等最新《可解释人工智能在网络安全应用》综述,33页pdf阐述其现状、挑战、开放问题和未来方向
- Go learning notes (4) basic types and statements (3)
- Qtablewidget control of QT
- Ask and answer: dispel your doubts about the virtual function mechanism
猜你喜欢

鹏城杯 WEB_WP

Baohong industry | good habits that Internet finance needs to develop

How to modify the network IP addresses of mobile phones and computers?

Reinforcement learning - learning notes 1 | basic concepts

Battle drag method 1: moderately optimistic, build self-confidence (1)

Experience summary of database storage selection

In 2021, the global revenue of thick film resistors was about $1537.3 million, and it is expected to reach $2118.7 million in 2028

Transformer structure analysis and the principle of blocks in it

Hcie security Day10: six experiments to understand VRRP and reliability

运维各常用命令总结
随机推荐
"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
Visiontransformer (I) -- embedded patched and word embedded
上周内容回顾
Is it OK for fresh students to change careers to do software testing? The senior answered with his own experience
Ask and answer: dispel your doubts about the virtual function mechanism
Transformation between yaml, Jason and Dict
电子科技大学|强化学习中有效利用的聚类经验回放
leetcode-540. A single element in an ordered array
Analysis of gas fee setting under eip1559
[gd32l233c-start] 5. FLASH read / write - use internal flash to store data
2022 melting welding and thermal cutting examination materials and free melting welding and thermal cutting examination questions
MySQL——SQL注入问题
Design e-commerce seckill system
JS three families
MySQL——规范数据库设计
MDM mass data synchronization test verification
MySQL 8.0 data backup and recovery
APEC industry +: father of the king of the ox mill, industrial Internet "king of the ox mill anti-wear faction" Valentine's Day greetings | Asia Pacific Economic media | ChinaBrand
Advanced collaboration: coroutinecontext
Goodbye 2021, how do programmers go to the top of the disdain chain?