当前位置:网站首页>MySQL and PostgreSQL methods to grab slow SQL
MySQL and PostgreSQL methods to grab slow SQL
2022-07-02 12:13:00 【alwaysonline819】
List of articles
1. MySQL Medium crawl slow SQL
- Check the related configuration of slow query
show variables like '%quer%';
- slow_query_log: Indicates whether to turn on the slow query log
- slow_query_log_file: Specify which log file the slow query log is stored in
- long_query_time: Indicates how long the query is recognized as " The slow query ". The default value is :10s
- log_queries_not_using_indexes: Indicates if it runs sql Indexes are not used , Whether it is also recorded in the slow query log as a slow query statement .
- log_throttle_queries_not_using_indexes: When log_queries_not_using_indexes Set to on when , This parameter limits the number of times a query statement that does not use an index is recorded in the slow query log per minute .
- Temporarily open / Turn off slow query log
set global slow_query_log = on
set global slow_query_log = off
- View slow query log
(1) Just started using slow queries ,vi or cat The command can still be used , You can also find , But as the number of logs grows , You may not be able to query , At this time, you need to use 2
(2)MySQL Built in mysqldumpslow Command analysis ( The specific use method can be Baidu )
2. PostgreSQL Grab slow SQL
- View the current slow query configuration
show log_min_duration_statement;
- stay postgresql.conf Configure global slow query log in ( millisecond )
log_min_duration_statement=10000;
- Slow query log location storage
log_destination = 'csvlog' # After opening this , below log_filename designated log The suffix file will have no content , All in csv In file
logging_collector = on
log_directory = 'pg_log' # In the current directory pg_log Folder
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
- Reload configuration
select pg_reload_conf();
- test
begin TRANSACTION;
select pg_sleep(5);
select now() ;
END TRANSACTION;
- see csv file , Filter duration Field
边栏推荐
- AI中台技术调研
- 史上最易懂的f-string教程,收藏這一篇就够了
- 5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
- From scratch, develop a web office suite (3): mouse events
- Larvel modify table fields
- 自然语言处理系列(一)——RNN基础
- Leetcode922 按奇偶排序数组 II
- 刷题---二叉树--2
- 字符串回文hash 模板题 O(1)判字符串是否回文
- LeetCode—剑指 Offer 51. 数组中的逆序对
猜你喜欢
随机推荐
drools决策表的简单使用
[C language] convert decimal numbers to binary numbers
测试左移和右移
计算二叉树的最大路径和
Leetcode922 sort array by parity II
lombok常用注解
GGHIGHLIGHT: EASY WAY TO HIGHLIGHT A GGPLOT IN R
输入一个三位的数字,输出它的个位数,十位数、百位数。
Small guide for rapid formation of manipulator (VII): description method of position and posture of manipulator
CONDA common command summary
Mish-撼动深度学习ReLU激活函数的新继任者
How does Premiere (PR) import the preset mogrt template?
Log4j2
LeetCode—剑指 Offer 37、38
B high and beautiful code snippet sharing image generation
(C language) octal conversion decimal
MySQL与PostgreSQL抓取慢sql的方法
单指令多数据SIMD的SSE/AVX指令集和API
Leetcode739 daily temperature
mysql表的增删改查(进阶)