当前位置:网站首页>SQL analysis (query interception analysis for SQL optimization)
SQL analysis (query interception analysis for SQL optimization)
2022-06-28 07:53:00 【Fairy wants carry】
Catalog
mysqldump Use ( Slow query analysis )

mysqldump Use ( Slow query analysis )
1. Open slow query log
SHOW VARIABLES LIKE 'slow_query_log';
# Open slow query log
SET GLOBAL slow_query_log=1;
# Threshold for slow queries
SHOW VARIABLES LIKE 'long_query_time';
SET long_query_time=0.1
2. Find the slow query log first
cd /var/lib/mysqlfind common.sock In the file is the slow query log

3. Use log analysis tools
mysqldumpsslw --help
Analyze as we do sql Optimization can use this log analysis
such as : Find the three slowest
mysqldumpslow -s c -t 3 -a
3. Find the corresponding sql Then go to centralized processing , You can go to sql Console explain The sql, Then proceed sql Index optimization
mysqldumpslow Parametric analysis

Common references for work :
Get the most returned recordset 10 individual SQL
mysqldumpslow -s r -t 10 /var/lib/mysql/atguigu-slow.log
The most visited 10 individual SQL
mysqldumpslow -s c -t 10 /var/lib/mysql/atguigu-slow.log
Get the top... In chronological order 10 There are left connected query statements in the bar
mysqldumpslow -s t -t 10 -g "left join" /var/lib/mysql/atguigu-slow.log
It is also recommended to use these commands in conjunction with | and more Use , Otherwise, the screen may explode
mysqldumpslow -s r -t 10 /var/lib/mysql/atguigu-slow.log | more
Kill users
# View user processes
SHOW PROCESSLIST
KILL 3
View
I'm only responsible for showing , There is no need to publish the program

1. Create view
CREATE VIEW view_name
AS
SELECT column_name(s)
FROM table_name
WHERE condition
2. After creating the view , Our future queries can be directly queried in the view ( What is encapsulated in the view itself is our sql)
View view
DELIMITER $$
ALTER ALGORITHM=UNDEFINED DEFINER=`root`@`%` SQL SECURITY DEFINER VIEW `view_test` AS
SELECT
`t_emp`.`id` AS `id`,
`t_emp`.`name` AS `name`,
`t_emp`.`age` AS `age`,
`t_emp`.`deptld` AS `deptld`,
`t_emp`.`empno` AS `empno`
FROM `t_emp`$$
DELIMITER ;Query the data according to the view
SELECT * FROM view_test边栏推荐
- Ambari (V) ---ambari integrated Azkaban (valid for personal test)
- 云原生:云计算技术再次升级 开启全面云开发时代
- ACM notes
- Conversion between HJ integer and IP address
- GoLand IDE and delve debug Go programs in kubernetes cluster
- Analyze 5 indicators of NFT project
- asp. Net registration page
- Unity UI shadow component
- flex布局
- 卸载重装最新版mysql数据库亲测有效
猜你喜欢

Soft exam -- software designer -- afternoon question data flow diagram DFD

Idea package together, using compact middle packages to solve &

Path alias specified in vite2.9

Design and implementation of spark offline development framework

扩展Prometheus的解决方案thanos的简介和几个月使用心得

asp. Net datalist to display product information and pictures

sql主从复制搭建

22/02/14 study notes

Soft test -- software designer -- database design of afternoon questions

The solution of "user account control to continue, please enter administrator user name and password" appears in win10 Professional Edition
随机推荐
HJ base conversion
股票炒股注册开户靠谱吗?安全吗?
Study notes 22/1/10
Section VII starting principle and configuration of zynq
Software design of resistance test board
【js】-【DFS、BFS应用】-学习笔记
逆波兰表达式求值<难度系数>
HJ delete the character with the least number of occurrences in the string
同花顺注册开户靠谱吗?安全吗?
Introduction and several months' experience of extending the solution thanos of Prometheus
Ambari (V) ---ambari integrated Azkaban (valid for personal test)
Host is not allowed to connect to this MySQL server
Understanding of OPC protocol
SOC clock configuration
Hash slot of rediscluster cluster cluster implementation principle
2021 programming language ranking summary
A single node obtains the lock lock of the order number
HJ character count
分析 NFT 项目的 5 个指标
Uninstall and reinstall the latest version of MySQL database. The test is valid