当前位置:网站首页>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边栏推荐
- Section VII starting principle and configuration of zynq
- HJ明明的随机数
- Software design of power control board
- GPIO configuration of SOC
- Block transmission by golang gin framework
- 8 figures | analyze Eureka's first synchronization registry
- Section 5: zynq interrupt
- ES6 use of return in arrow function
- Ice - resources
- 异或的应用。(提取出数字中最右侧的1,面试中经常用的到)
猜你喜欢

Path alias specified in vite2.9

Sentinel mechanism of redis cluster

Recommended system series (Lecture 5): Optimization Practice of sorting model

Section Xi. Axi of zynq_ Use of DMA

Kubelet garbage collection (exiting containers and unused images) source code analysis

Kubernetes deploys a secret pit where thanos ruler sends repeated alarms

Tencent continued to lay off staff in the second half of the year, and all business groups reduced by at least 10%. What do you think of this? Followers

Configuring MySQL multi instance master-slave synchronization for Linux

Block transmission by golang gin framework

What is EC blower fan?
随机推荐
Ambari (VIII) --- ambari integrated impala document (valid for personal test)
MySQL installation and environment variable configuration
Soft exam -- software designer -- afternoon question data flow diagram DFD
HJ character count
Ambari (VI) -- ambari API use
[ thanos源码分析系列 ]thanos query组件源码简析
Disposition Flex
flex布局
Real time database - Notes
自动化测试的生命周期是什么?
Cloud native (to be updated)
Co process, asyncio, asynchronous programming
8 figures | analyze Eureka's first synchronization registry
HJ整数与IP地址间的转换
ACM notes
HJ delete the character with the least number of occurrences in the string
No suspense about the No. 1 Internet company overtime table
GoLand IDE and delve debug Go programs in kubernetes cluster
Block transmission by golang gin framework
es6箭头函数中return的用法