Mysql 5.7优化

为了达到数据库胡最佳性能

1. 普通用户通过配置软件与硬件来实现

2. 高级用户会寻求机会改善MySQL本身,开发自己的数据存储引擎,硬件应用。

在数据库层面的优化

  1. 表设计,通常列有适合的数据类型,表有适合的列。例子,写操作多的应有通常有多点表,少点列。

大量的数据分析的,会多点列,少些表。

        2. 建立适合的索引。

        3. 使用适合的存储引擎。

 优化select语句。

  例子:

    优化InnoDB Queries

    如果列中不可能有NULL,声明为NOT NULL更有利于优化器 

              不要单独建立二级索引,因为每次查询只使用一个索引。尝试使用组合索引。

  

 行级锁:InnoDB多用户,高并发,在线计算

为了防止死锁,InnoDB可以自动发现死锁条件,回滚。

在高并发系统里,这个机制导致缓慢。所以disable 死锁检测,依靠innodb_lock_wait_timeout, innodb_deadlock_detect这个可以关掉。

https://dev.mysql.com/doc/refman/5.7/en/table-locking.html

To specify that all updates issued in a specific connection should be done with low priority, set the low_priority_updates server system variable equal to 1.

When tuning a MySQL server, the two most important variables to configure are key_buffer_size and table_open_cache. You should first feel confident that you have these set appropriately before trying to change any other variables.

猜你喜欢

转载自www.cnblogs.com/studyNT/p/9368427.html