The road to mysql optimization ------ summary

1 Overview:
Database performance depends on database-level elements such as tables, queries, and configuration settings; these software-level constructs affect CPU and IO operations at the hardware level, and these are elements that you need to reduce as much as possible and make them run efficiently. Traditional users generally obtain the best performance of the database through software and hardware configuration, while high-end users expand the MYSQL ecosystem by improving the software itself or by developing their own storage engines and hardware devices.
2. How to optimize
1) Optimization at the database level: The most important element to make the database more blocky is its basic design.
Appropriate table structure ? In particular the columns are set to the correct data types , with the appropriate columns for each table? For example, the application should not frequently update a few columns in a large number of tables, but a large number of columns in a small number of tables.
★ Is the correct index set to make the query more efficient?
Each table uses a suitable storage engine and gains the advantages and characteristics of the storage engine. In particular, the choice of transactional storage engine innoDB and non-transactional storage engine MyISAM may be important for performance and scalability.
★ Use the appropriate row format for each table ; this also depends on the storage engine used by the table. In particular, the table compression table uses less disk space and uses less disk IO to read and write data. Compression is valid for InnoDB tables and read-only MyISAM tables for all workloads.
应用程序采用来 合适的锁策略 。如可能的时候通过允许共享访问使数据库操作可以并发运行,而且专用请求访问也可以在可能的时候获取更高的优先级。还有存储引擎的选择很重要,InnoDB可以不用你参与的情况下解决绝大部分锁问题,允许更好的并发并减少很多实现和代码调整。
所有内存区域使用的 缓存大小 是否合适?足够大到保持住频繁的数据访问,而不是足够大以至于超过物理内存并引起分页;主内存区域的配置包括InnoDB缓存池、MyISAM键缓存和MYSQL查询缓存。
2)硬件层面的优化:数据库应用最终会越来越多的触碰到硬件的限制,DBA需要评估是否调整应用程序或重新配置服务器以避免系统瓶颈 ,更或者需要更多的硬件资源
磁盘寻道(DISK SEEK):从磁盘获取一段数据的带来的时间。现代的磁盘一般获取时间一般低于10ms,这样理论上100次寻道就是1s,但是对于单表,这样的通过磁盘寻道去优化时间是很难的,一般优化寻道时间的方式是通过把数据分别存储到多个磁盘上。
磁盘读写:当磁盘寻道到正确的位置,我们需要读取和写入数据。现代磁盘传输数据至少10~20M/s的吞吐量。这是比磁盘寻道更容易的方法,因为你可以并发读多个磁盘。
CPU周期(CPU cycles):数据在主内存时,我们必须处理它获取结果。内存中的大表的比较是一个较普遍的限制,但是对于小表,速度不是问题
内存带宽:CPU需要更多的数据命中CPU缓存,这时主内存带宽变成了一个瓶颈;这个在大多数系统是不普遍的,但是要注意。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324549273&siteId=291194637