当前位置:网站首页>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
边栏推荐
- ES集群中节点与分片的区别
- arcgis js 4.x 地图中加入图片
- LeetCode—<动态规划专项>剑指 Offer 19、49、60
- Take you ten days to easily finish the finale of go micro services (distributed transactions)
- (C language) octal conversion decimal
- drools执行String规则或执行某个规则文件
- Yygh-10-wechat payment
- 甜心教主:王心凌
- Find the factorial of a positive integer within 16, that is, the class of n (0= < n < =16). Enter 1111 to exit.
- Experiment of connecting mobile phone hotspot based on Arduino and esp8266 (successful)
猜你喜欢

H5,为页面添加遮罩层,实现类似于点击右上角在浏览器中打开

Deep understanding of P-R curve, ROC and AUC

基于Arduino和ESP8266的Blink代码运行成功(包含错误分析)

Docker-compose配置Mysql,Redis,MongoDB

5g era, learning audio and video development, a super hot audio and video advanced development and learning classic

【C语言】十进制数转换成二进制数

Jenkins user rights management

排序---

深入理解P-R曲线、ROC与AUC

PyTorch搭建LSTM实现服装分类(FashionMNIST)
随机推荐
Lekao: contents of the provisions on the responsibility of units for fire safety in the fire protection law
全链路压测
Depth filter of SvO2 series
kubeadm join时出现错误:[ERROR Port-10250]: Port 10250 is in use [ERROR FileAvailable--etc-kubernetes-pki
Full link voltage measurement
Le tutoriel F - String le plus facile à comprendre de l'histoire.
Take you ten days to easily finish the finale of go micro services (distributed transactions)
Leetcode209 subarray with the smallest length
刷题---二叉树--2
Maximum profit of jz63 shares
H5,为页面添加遮罩层,实现类似于点击右上角在浏览器中打开
堆(優先級隊列)
From scratch, develop a web office suite (3): mouse events
Multiply LCA (nearest common ancestor)
Brush questions --- binary tree --2
Codeforces 771-div2 C (trouble, permutation is not very good)
Leetcode122 the best time to buy and sell stocks II
5g era, learning audio and video development, a super hot audio and video advanced development and learning classic
Yygh-10-wechat payment
基于Arduino和ESP8266的连接手机热点实验(成功)