Performance Optimization-mysql database

Source: Internet
Author: User

Performance Optimization-mysql database

I. mysql Common commands

1. Open the log

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

2) set global general_log = on;

3) set global general_log = off;

2. If set autocommit = 0 is enabled for mysql, all statements must be in one transaction.

3. show engine innodb status

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

Typical Problem Analysis

1. Database waiting Lock timeout Lock wait timeout exceeded; try restarting transaction

1 ). adjust the statement execution sequence to reduce lock wait time: There are many database operations involved, and the transaction is large. Tables with lock timeout (multiple transaction concurrency may take tables with the same row, there will be a lock wait situation) at the end of the transaction, the lock will be released after execution, reducing the lock wait time of other transactions
2). Split the transaction:
3) Statement merge to reduce network interaction between databases: multiple statements are combined, and multiQuery is used for one query update.

2. DeadLock Problems

3. Check that the transaction has not been committed.

Mysql> show engine innodb status \ G

Query the active transaction id

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.