当前位置:网站首页>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
边栏推荐
- Learning Android from scratch -- baseactivity and activitycollector
- Sword finger offer: the path with a certain value in the binary tree (backtracking)
- L2-011 玩转二叉树(建树+BFS)
- Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
- 信息学奥赛一本通 1955:【11NOIP普及组】瑞士轮 | OpenJudge 4.1 4363:瑞士轮 | 洛谷 P1309 [NOIP2011 普及组] 瑞士轮
- CLion+OpenCV identify ID number - detect ID number
- Innovation training (II) task division
- Pixel mobile phone brick rescue tutorial
- Learning Android V from scratch - UI
- [winui3] write an imitation Explorer file manager
猜你喜欢
![[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测](/img/7c/51ac43080d9721f1bdc1cd78cd685b.png)
[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测

redis数据类型有哪些

Simply drag objects to the item bar

Practice and exploration of knowledge map visualization technology in meituan

Set Chrome browser background to eye protection (eye escort / darkreader plug-in)

Opencv + clion face recognition + face model training

New terminal play method: script guidance independent of technology stack

CLion+OpenCV identify ID number - detect ID number

Thoughts on a small program

独立站运营 | FaceBook营销神器——聊天机器人ManyChat
随机推荐
Wechat payment function
The last day of 2021 is the year of harvest.
Unity攝像頭跟隨鼠標旋轉
Innovation training (XI) airline ticket crawling company information
Unity3d practical skills - theoretical knowledge base (I)
C# List字段排序含有数字和字符
Flink case - Kafka, MySQL source
Graduation project
POI export message list (including pictures)
Better way to read configuration files than properties
深度学习笔记 —— 物体检测和数据集 + 锚框
Progress of innovation training (IV)
C language: Advanced pointer
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
Other problems encountered in debugging fingerprints
Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)
Opencv + clion face recognition + face model training
[winui3] write an imitation Explorer file manager
PHP counts the number of files in the specified folder
Making message board with PHP + MySQL