当前位置:网站首页>MySQL memo (for your own query)
MySQL memo (for your own query)
2022-04-23 04:55:00 【P&p】
1.1 Grant authority
GRANT Permission list ON Database name . Table name TO ‘ user name ’@‘ Source address ’ [IDENTIFIED BY ‘ password ’];
Allow users company Query at all terminals hrm All the tables under the database .
GRANT select ON hrm.* TO ‘company’@‘%’ [IDENTIFIED BY ‘123456]’;
Allow users company Database at all terminals hrm Perform all operations
GRANT ALL ON hrm.* TO ‘company’@‘%’ [IDENTIFIED BY ‘123456]’;
Be careful After all authorized operations are completed Refresh permissions are required !
flush privileges;
1.2 utilize EXPLAIN Perform performance analysis
The main thing is to add keywords in front of the query statement EXPLAIN.
Through the above keywords , We can get the reading order of the table 、 Operation type 、 The index that can be used and the index used in time and other important data , From this, we can see that this article sql Whether the best performance is achieved !
Here is an example :
Among the results obtained above are 12 A field :
The more important fields are described below :
- id The serial number of the query Represents execution in a query select The order of clauses or operation tables
- type Query usage type From good to bad system > const > eq_ref > ref > range > index > all
- possible_keys Index available
- key Index actually used
Following pair type Further description of each type :
1、system The system tables There is only one line in the table , The ideal situation that basically won't happen :
2、const Indicates that it is found through index once . For example, put the primary key in where In the list ,MySQL You can convert the query to a constant .
3、eq_ref Uniqueness index . For each index key , Only one record in the table matches it . Common in primary key or unique index scan
4、ref Non unique index
5、range Retrieve only rows in the given range Generally speaking, it is where of use Greater than less than in between Wait to find multiple conditions
6、index Scan the whole table But this is read from the index
7、all Full table scan Read from the hard disk
Generally speaking, at least range Level !
版权声明
本文为[P&p]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220553315631.html
边栏推荐
- The last day of 2021 is the year of harvest.
- Last day of 2017
- List remove an element
- Unity C# 网络学习(四)
- Graduation project
- JS engine loop mechanism: synchronous, asynchronous, event loop
- Learning Android from scratch -- Introduction
- CLion+OpenCV identify ID number - detect ID number
- Eight misunderstandings that should be avoided in data visualization
- Innovation training (VI) routing
猜你喜欢
Wechat payment function
MySQL - index
Arduino UNO r3+LCD1602+DHT11
深度学习笔记 —— 微调
Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘
[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测
What are the redis data types
[2021] Spatio-Temporal Graph Contrastive Learning
Thoughts on a small program
DIY is an excel version of subnet calculator
随机推荐
What is a data island? Why is there still a data island in 2022?
MySQL - index
信息学奥赛一本通 1212:LETTERS | OpenJudge 2.5 156:LETTERS
Com alibaba. Common methods of fastjson
Eight misunderstandings that should be avoided in data visualization
The object needs to add additional attributes. There is no need to add attributes in the entity. The required information is returned
Shanghai Hangxin technology sharing 𞓜 overview of safety characteristics of acm32 MCU
Windows remote connection to redis
Unity3D 实用技巧 - 理论知识库(一)
Details related to fingerprint payment
敏捷实践 | 提高小组可预测性的敏捷指标
Graduation project
View, modify and delete [database] table
Innovation training (V) mid term inspection
Progress of innovation training (IV)
[winui3] write an imitation Explorer file manager
Getprop property
Better way to read configuration files than properties
POI export message list (including pictures)
用LCR表完美测试无线充电系统中的线圈