MySQL optimization: How to understand the execution frequency of SQL _ MySQL

Source: Internet
Author: User
MySQL optimization: How to understand the SQL execution frequency show [session | global] status. you can add the parameter "session" or "global" as needed to display the session level (current connection) and global (since the last time the database was started. If this parameter is not specified, the default parameter "session" is used ".

Com_xxx indicates the number of times each xxx statement is executed. we usually care about the following statistical parameters:

• Com_select: number of select operations performed. only one value is added for one query.
• Com_insert: the number of INSERT operations performed. INSERT operations in batches are accumulated only once.
• Com_update: the number of times the UPDATE operation is performed.
• Com_delete: the number of DELETE operations.

Knowing this information makes it easy for us to determine what storage engine we need. Generally, when there are many updates, Innodb engine efficiency will be slightly higher!

The preceding parameters are used to accumulate table operations for all storage engines. The following parameters are only for the InnoDB storage engine, and the tired algorithm is slightly different:

• Innodb_rows_read: number of rows returned by the select statement.
• Innodb_rows_inserted: number of rows inserted by the INSERT operation.
• Innodb_rows_updated: number of rows updated by the UPDATE operation.
• Innodb_rows_deleted: number of rows deleted by the DELETE operation.

With the above parameters, you can easily understand whether the current database application is dominated by insert and update, query operations, and the approximate execution ratio of various types of SQL statements. The Count of update operations is the count of the number of executions. Both the commit and rollback operations are accumulated.
For transactional applications, you can use Com_commit and Com_rollback to learn about transaction commit and rollback. for databases with frequent rollback operations, it may mean that there is a problem in application writing.
In addition, the following parameters help us understand the basic information of the database:

• Connections: number of attempts to connect to the MySQL server.
• Uptime: the server's working time.
• Slow_queries: the number of slow queries.

The above is how to understand the SQL execution frequency of MySQL for MySQL optimization. For more information, see PHP Chinese network (www.php1.cn )!

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.