当前位置:网站首页>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
边栏推荐
- Take you ten days to easily finish the finale of go micro services (distributed transactions)
- 深入理解PyTorch中的nn.Embedding
- Leetcode209 长度最小的子数组
- (C语言)3个小代码:1+2+3+···+100=?和判断一个年份是闰年还是平年?和计算圆的周长和面积?
- [geek challenge 2019] upload
- Natural language processing series (III) -- LSTM
- 自然语言处理系列(二)——使用RNN搭建字符级语言模型
- SparkContext: Error initializing SparkContext解决方法
- 基于Arduino和ESP8266的连接手机热点实验(成功)
- Lekao: contents of the provisions on the responsibility of units for fire safety in the fire protection law
猜你喜欢

Map和Set

(C language) 3 small Codes: 1+2+3+ · · +100=? And judge whether a year is a leap year or a normal year? And calculate the circumference and area of the circle?

From scratch, develop a web office suite (3): mouse events

Jenkins用户权限管理

CDA data analysis -- Introduction and use of aarrr growth model

mysql表的增删改查(进阶)

MySQL indexes and transactions

Read the Flink source code and join Alibaba cloud Flink group..

SVO2系列之深度濾波DepthFilter

SparkContext: Error initializing SparkContext解决方法
随机推荐
YYGH-BUG-05
Time format display
Take you ten days to easily finish the finale of go micro services (distributed transactions)
Addition, deletion, modification and query of MySQL table (Advanced)
Leetcode209 subarray with the smallest length
自然语言处理系列(三)——LSTM
Differences between nodes and sharding in ES cluster
drools执行String规则或执行某个规则文件
堆(優先級隊列)
H5, add a mask layer to the page, which is similar to clicking the upper right corner to open it in the browser
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
寻找二叉树中任意两个数的公共祖先
Codeforces 771 div2 B (no one FST, refers to himself)
PyTorch nn.RNN 参数全解析
LeetCode—剑指 Offer 59 - I、59 - II
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
Jenkins用户权限管理
Leetcode14 最长公共前缀
Mish-撼动深度学习ReLU激活函数的新继任者
Uniapp uni list item @click, uniapp uni list item jump with parameters