Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement slow query Log in MySQL

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

Today, I will talk to you about how to implement the slow query log in MySQL. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

The most basic is the mysqlslowdump that comes with it.

It's easy to use:

Mysqldumpslow-s c-t 20 host-slow.log

Parameters:

1.-s, sort, cPeragne, ac,at,al,ar, and ac,at,al,ar are sorted according to query times, time, lock time, and return records, respectively. To add an is to reverse the order.

2.-t top n, keep up with the number is to calculate the number of top

3.-g, followed by regular expressions.

The more advanced one is mysqlsla, which is also a perl script.

Web site:

At the same time, this site also has some other tools, all of which look good.

This requires a small installation:

Tar xvfz mysqlsla-2.03.tar.gz

Cd mysqlsla-2.03

Perl Makefile.PL

Make

Make install

Note that you need the support of perl!

# yum install perl

# yum install perl-Time-HiRes

The latter is because the first time it was run, it said that line 2095 reported an error, so I took a look at it. Line 2095 is

Use Time::HiRes qw (gettimeofday tv_interval)

Just install it. It's not complicated.

It is also relatively simple to run:

-Slow log: mysqlsla-lt slow slow.log

-General log: mysqlsla-lt general general.log

-Binary log: mysqlbinlog bin.log | mysqlsla-lt binary

Mysqlsla-lt slow / data/database/slow.log

Notice lt=log type, who can actually analyze other log types of mysql.

After reading the above, do you have any further understanding of how to implement slow query logs in MySQL? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report