当前位置:网站首页>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
边栏推荐
- Capture de paquets et tri du contenu externe - - autoresponder, composer, statistiques [3]
- Measurement fitting based on Halcon learning -- Practice [1]
- Offset related concepts + drag modal box case
- Recommendation of books related to strong foundation program mathematics
- Qualcomm platform WiFi update disconnect end open event
- 全网都在疯传的《老板管理手册》(转)
- Node MySQL serialize cannot rollback transactions
- Visiontransformer (I) -- embedded patched and word embedded
- 淺析 Ref-NeRF
- Hcie security Day10: six experiments to understand VRRP and reliability
猜你喜欢

jvm jni 及 pvm pybind11 大批量数据传输及优化

The "boss management manual" that is wildly spread all over the network (turn)

你真的知道自己多大了吗?

Basic knowledge of dictionaries and collections

Basic preprocessing and data enhancement of image data
![[secretly kill little buddy pytorch20 days -day02- example of image data modeling process]](/img/14/8ab1f1fb142e10dead124851180d03.jpg)
[secretly kill little buddy pytorch20 days -day02- example of image data modeling process]

Leetcode daily question 540 A single element in an ordered array Valentine's Day special article looking for a single dog in a pile of lovers ~ the clown is myself

Etcd 基于Raft的一致性保证

Yyds dry goods inventory TCP & UDP

Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022
随机推荐
Rhcsa third day notes
What is the maximum number of concurrent TCP connections for a server? 65535?
CesiumJS 2022^ 源码解读[7] - 3DTiles 的请求、加载处理流程解析
@Transactional注解失效的场景
Go learning notes (4) basic types and statements (3)
(5) Web security | penetration testing | network security operating system database third-party security, with basic use of nmap and masscan
鹏城杯 WEB_WP
Operate BOM objects (key)
Node MySQL serialize cannot rollback transactions
MySQL——SQL注入问题
Discussion Net legacy application transformation
[Yugong series] go teaching course 002 go language environment installation in July 2022
[postgresql]postgresql custom function returns an instance of table type
The 12th Blue Bridge Cup
Research Report on the overall scale, major manufacturers, major regions, products and application segmentation of rotary tablet presses in the global market in 2022
The global industrial design revenue in 2021 was about $44360 million, and it is expected to reach $62720 million in 2028. From 2022 to 2028, the CAGR was 5.5%
How to handle wechat circle of friends marketing activities and share production and release skills
Leetcode daily question 540 A single element in an ordered array Valentine's Day special article looking for a single dog in a pile of lovers ~ the clown is myself
Hcie security Day11: preliminarily learn the concepts of firewall dual machine hot standby and vgmp
Qualcomm platform WiFi update disconnect end open event