当前位置:网站首页>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边栏推荐
- HJ character count
- 扩展Prometheus的解决方案thanos的简介和几个月使用心得
- kubernetes部署thanos ruler的发送重复告警的一个隐秘的坑
- 7-1 understand everything
- Study notes 22/1/10
- Flex layout
- asp. Net to search products and realize paging function
- Airflow2.1.1 ultra detailed installation document
- 协程、asyncio、异步编程
- Sword finger offer|: linked list (simple)
猜你喜欢

Disposition Flex

什么是EC鼓风机(ec blower fan)?

Source code analysis of kubernetes' process of deleting pod

sql主从复制搭建

Online WPS tool

asp. Net datalist when there are multiple data displays

Sword finger offer|: linked list (simple)

asp. Net datalist to display product information and pictures

软件测试与质量期末复习

Design and implementation of spark offline development framework
随机推荐
Cloud native: cloud computing technology is upgraded again to open an era of comprehensive cloud development
Makefile
Redis one master multi slave cluster setup
Ambari (VIII) --- ambari integrated impala document (valid for personal test)
Llvm and clang
GoLand IDE and delve debug Go programs in kubernetes cluster
flutter 实现摇一摇功能
How to configure DDR3 of dm8148
Is it reliable for securities companies to register and open accounts? Is it safe?
同花顺注册开户靠谱吗?安全吗?
Design and implementation of spark offline development framework
SOC timer and interrupt configuration
2021 programming language ranking summary
Is it safe for flush to open an account online
Ambari (V) ---ambari integrated Azkaban (valid for personal test)
Is it safe to open an account on Dongfang fortune
Study notes 22/1/19 and 22/1/20
asp. Net datalist to display product information and pictures
Explanation and application of instr() function in Oracle
Section 9: dual core startup of zynq