当前位置:网站首页>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/mysql
find 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
边栏推荐
猜你喜欢
Sword finger offer|: linked list (simple)
asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
Airflow2.1.1 ultra detailed installation document
MySQL installation and environment variable configuration
HJ质数因子
[ thanos源码分析系列 ]thanos query组件源码简析
Section 8: DMA of zynq
8 figures | analyze Eureka's first synchronization registry
Ambari (VII) --- ambari integrated hue4.2 document (valid for personal test)
Application of XOR. (extract the rightmost 1 in the number, which is often used in interviews)
随机推荐
逆波兰表达式求值<难度系数>
Kubernetes理论基础
"Three routines" of digital collection market
Online WPS tool
Open62541 import nodeset file directly
Spark 离线开发框架设计与实现
Today's notes 22/1/7
golang gin框架进行分块传输
什么是EC鼓风机(ec blower fan)?
Is it safe to open an account on Dongfang fortune
Study notes 22/1/18
Section 8: DMA of zynq
Is it reliable to register and open an account for stock speculation? Is it safe?
Soft test -- software designer -- database design of afternoon questions
HJ base conversion
flex布局
HJ字符串排序
asp. Net error "/" server error in the application. String or binary data would be truncated. The statement...
Is it safe for flush to open an account online
SOC timer and interrupt configuration