Mysql prompts Writingtonet_MySQL

Source: Internet
Author: User
Recently, it was found that the cpu usage of a database has been compared. More than 200%. First, check the slow log of the database and set the slow log to 5 seconds. basically, no daily log is generated and no more than 5 seconds are generated. Showprocesslist; it takes 1-2 seconds to query several select tables. explainselec recently found that the cpu usage of a database has been compared. More than 200%.

First, check the slow log of the database and set the slow log to 5 seconds. basically, no daily log is generated and no more than 5 seconds are generated.

Show processlist;

It takes 1-2 seconds to query several select tables,

Explain select * from xxx, found that no index, full table scan, the amount of data in the past will soon come out, the current total query data is less than 20 thousand, now the amount of data is large, all other tables are at the level of. Previously, only the indexes of large tables were optimized, so the problem was highlighted. After the index is created, the CPU usage is clearly reduced. as far as I know, the cpu usage of msyql is high, which is related to 80% of the cases where no index is used.

In the next show processlist

Multiple statements are found to be in the Writing to net state.

The analysis is basically a select statement, and the query data is too large. the database returns a network write-back failure,

View show global variables like "global max_allowed_packet" only 1 M

Add cache

Set global max_allowed_packet = 134217728

The problem is solved! The reason is that the number of data returned by multiple select statements exceeds the default value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.