Performance Optimization--mysql Database

Source: Internet
Author: User

One MySQL often uses commands

1. Open the Log

1) show global variables like "%genera%";

2)set global general_log=on;

3)set global general_log=off;


2. MySQL assumes that set autocommit=0 is open, then all statements must be in one transaction


3. Show Engine InnoDB status

1) http://imysql.cn/2008_05_22_walk_through_show_innodb_status



Analysis of two typical problems

1. Database waits for lock timeout lock wait timeout exceeded; Try restarting transaction

1). Adjust the order in which statements are run. Reduce lock wait time: It involves more database operations and larger transactions. The tables that have these locks timed out (multiple transactions may take the same row of tables, there will be lock waits) are placed on the last side of the transaction, and the lock is released when it runs out. Reduce lock wait time for other transactions
2). Slicing transactions:
3). Statement merging. Reduce Database Network Interaction: Multiple statements, and together. Use Multiquery, one query update


2. Deadlock issues


3. View issues that have not been submitted by the transaction

Mysql> Show engine InnoDB status \g

Querying the transaction ID for active




Appendix:

MySQL Lock analysis: http://hedengcheng.com/?p=771


Performance Optimization--mysql Database

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.