Home Database Mysql Tutorial 性能优化mysql数据库_MySQL

性能优化mysql数据库_MySQL

Jun 01, 2016 pm 01:01 PM
performance database

一 mysql常用命令

1. 打开日志

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

2)set global general_log=on;

3)set global general_log=off;

2. mysql如果开了set autocommit=0,那么所有的语句一定是在一个事务里

3. show engine innodb status

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

二 典型问题分析

1. 数据库等待锁超时 Lock wait timeout exceeded; try restarting transaction

1). 调整语句执行顺序,减少锁等待时间:涉及到的数据库操作比较多,事务比较大,把这些锁超时的表(多个事务并发可能取同一行的表,就会存在锁等待的情况)放在事务的最后面,执行完就释放锁了,减少其他事务的锁等待时间
2).切分事务:
3).语句合并,减少数据库网络交互:多条语句,并在一起,使用multiQuery,一次查询更新

2. DeadLock问题

3. 查看事务一直没提交的问题

mysql> show engine innodb status \G

查询active 的事务id

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Performance comparison of different Java frameworks Performance comparison of different Java frameworks Jun 05, 2024 pm 07:14 PM

Performance comparison of different Java frameworks

How to optimize the performance of multi-threaded programs in C++? How to optimize the performance of multi-threaded programs in C++? Jun 05, 2024 pm 02:04 PM

How to optimize the performance of multi-threaded programs in C++?

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

Detailed tutorial on establishing a database connection using MySQLi in PHP

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos

Performance comparison of C++ with other languages Performance comparison of C++ with other languages Jun 01, 2024 pm 10:04 PM

Performance comparison of C++ with other languages

How does Go WebSocket integrate with databases? How does Go WebSocket integrate with databases? Jun 05, 2024 pm 03:18 PM

How does Go WebSocket integrate with databases?

How to use database callback functions in Golang? How to use database callback functions in Golang? Jun 03, 2024 pm 02:20 PM

How to use database callback functions in Golang?

How to handle database connection errors in PHP How to handle database connection errors in PHP Jun 05, 2024 pm 02:16 PM

How to handle database connection errors in PHP

See all articles