性能优化mysql数据库_MySQL
Jun 01, 2016 pm 01:01 PM一 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

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Performance comparison of different Java frameworks

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

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

Performance comparison of C++ with other languages

How does Go WebSocket integrate with databases?

How to use database callback functions in Golang?

How to handle database connection errors in PHP
