当前位置:网站首页>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
边栏推荐
- Unity camera rotation with sliding effect (rotation)
- [database] MySQL single table query
- L2-011 play binary tree (build tree + BFS)
- [WinUI3]编写一个仿Explorer文件管理器
- Spark small case - RDD, broadcast
- Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
- Opencv + clion face recognition + face model training
- Innovation training (XII) reptile
- Use model load_ state_ Attributeerror appears when dict(): 'STR' object has no attribute 'copy‘
- Last day of 2017
猜你喜欢

DIY 一个 Excel 版的子网计算器

Flink's important basics

Pixel mobile phone brick rescue tutorial

Customize the navigation bar at the top of wechat applet (adaptive wechat capsule button, flex layout)

深度学习笔记 —— 微调

深度学习笔记 —— 数据增广

独立站运营 | FaceBook营销神器——聊天机器人ManyChat

Programmers complain: I really can't live with a salary of 12000. Netizen: how can I say 3000

【数据库】表的查看、修改和删除

Teach you how to build the ruoyi system by Tencent cloud
随机推荐
Learning Android from scratch -- Introduction
Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
PIP3 installation requests Library - the most complete pit sorting
Innovation training (XII) reptile
L2-011 play binary tree (build tree + BFS)
Teach you how to build the ruoyi system by Tencent cloud
MySQL - data read / write separation, multi instance
Solve valueerror: argument must be a deny tensor: 0 - got shape [198602], but wanted [198602, 16]
Unity3d practical skills - theoretical knowledge base (I)
【数据库】MySQL单表查询
Field injection is not recommended using @ Autowired
Spark case - wordcount
Sword finger offer: the median in the data stream (priority queue large top heap small top heap leetcode 295)
持续集成(CI)/持续交付(CD)如何彻底改变自动化测试
General enumeration constant class
C language: Advanced pointer
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
No such file or directory problem while executing shell
MySQL time function query