Mysql prompts Writing to net Solution

Source: Internet
Author: User

Mysql prompts Writing to net to solve the problem. Recently, it 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 tables in several select statements. explain select * from xxx shows that the entire table is not indexed. In the past, when the data volume was small, it would be very short, currently, the total data to be queried is less than 20 thousand. Now the data volume is large, and the other tables are all levels. Previously, only the index of large tables was optimized, so the problem is 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. At show processlist, multiple statements are found to be in the Writing to net state. By analyzing these statements, select statements are basically used, and the database returns the network write-back result if the query data is too large, view show global variables like "global max_allowed_packet". The problem is solved only by adding 1 M cache set global max_allowed_packet = 134217728! The reason is that the number of data returned by multiple select statements exceeds the default value.

Related Article

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.