Home Database Mysql Tutorial 关于MYSQL的优化全面详解_MySQL

关于MYSQL的优化全面详解_MySQL

Jun 01, 2016 pm 01:23 PM

bitsCN.com 先说一下最常见基本的系统瓶颈:
1、硬盘搜索。现代磁盘的平均时间通常小于10ms,因此理论上我们每秒能够大约搜索1000次,这样我们在这样一个磁盘上搜索一个数据,很难优化,一个办法就是将数据分布在多个磁盘。
2、IO读写。就磁盘来讲,一般传输10-20Mb/s,同样的,优化可以从多个磁盘并行读写。
3、CPU周期。我们将数据读入内存后,需要对它进行处理并获取我们需要的结果。表相对于内存较小时常见的限制因素。但是对于小表,速度通常不成问题。
4、内存带宽。当CPU需要的数据超出CPU缓存,主缓存带宽就成为内存的一个瓶颈。

再说一下mysql设计上边的瓶颈:(本人了解一下它的数据库引擎,wiki上边说的一些缺陷)
MyISAM是MySQL的默认数据库引擎 (5.5版之前),由早期的ISAM所改良。虽然性能极佳,但却有一个缺点:不支持code error!(transaction)。不过,在这几年的发展下,MySQL也导入了InnoDB (另一种数据库引擎),以强化code error!与并发违规处理机制,后来就逐渐取代MyISAM。
每个MyISAM数据表,皆由存储在硬盘上的3个文件所组成,每个文件都以数据表名称为主文件名,并搭配不同扩展名区分文件类型:
.frm--存储数据表定义,此文件非MyISAM引擎的一部份。
.MYD--存放真正的数据。
.MYI--存储索引信息。

1、InnoDB可借由交易记录档 (Transaction Log) 来恢复程序崩溃 (crash),或非预期退出所造成的数据错误;而MyISAM遇到错误,必须完整扫描后才能重建索引,或修正未写入硬盘的错误。InnoDB的修复时间,大略都是固定的,但MyISAM的修复时间,则与数据量的多寡成正比。相对而言,随着数据量的增加,InnoDB会有较佳的稳定性。
2、MyISAM必须依靠操作系统来管理读取与写入的高速缓存,而InnoDB则是有自己的读写高速缓存管理机制。(InnoDB不会将被修改的code error!立即交给操作系统) 因此在某些情况下,InnoDB的数据访问会比MyISAM更有效率。
3、InnoDB目前并不支持MyISAM所提供的压缩与 terse row formats,所以对硬盘与高速缓存的使用量较大。因此MySQL从5.0版开始,提供另一个负载较轻的格式,他可减少约略 20% 的系统负载,而压缩功能已计划于未来的新版中推出。
4、当操作完全兼容ACID (code error!) 时,虽然InnoDB会自动合并数笔连接,但每次有code error!产生时,仍至少须写入硬盘一次,因此对于某些硬盘或磁盘阵列,会造成每秒200次的code error!处理上限。若希望达到更高的性能且保持code error!的完整性,就必使用软盘高速缓存与电池备援。当然 InnoDB 也提供数种对性能冲击较低的模式,但相对的也会降低code error!的完整性。而MyISAM则无此问题,但这并非因为它比较先进,这只是因为它不支持code error!。

(InnoDB,是MySQL的数据库引擎之一,为MySQL AB发行binary的标准之一。InnoDB由Innobase Oy公司所开发,2006年五月时由甲骨文公司并购。与传统的ISAM与MyISAM相比,InnoDB的最大特色就是支持了ACID兼容的事务(Transaction)功能,类似于PostgreSQL。)bitsCN.com

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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)

When might a full table scan be faster than using an index in MySQL? When might a full table scan be faster than using an index in MySQL? Apr 09, 2025 am 12:05 AM

Full table scanning may be faster in MySQL than using indexes. Specific cases include: 1) the data volume is small; 2) when the query returns a large amount of data; 3) when the index column is not highly selective; 4) when the complex query. By analyzing query plans, optimizing indexes, avoiding over-index and regularly maintaining tables, you can make the best choices in practical applications.

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

Explain InnoDB Full-Text Search capabilities. Explain InnoDB Full-Text Search capabilities. Apr 02, 2025 pm 06:09 PM

InnoDB's full-text search capabilities are very powerful, which can significantly improve database query efficiency and ability to process large amounts of text data. 1) InnoDB implements full-text search through inverted indexing, supporting basic and advanced search queries. 2) Use MATCH and AGAINST keywords to search, support Boolean mode and phrase search. 3) Optimization methods include using word segmentation technology, periodic rebuilding of indexes and adjusting cache size to improve performance and accuracy.

Difference between clustered index and non-clustered index (secondary index) in InnoDB. Difference between clustered index and non-clustered index (secondary index) in InnoDB. Apr 02, 2025 pm 06:25 PM

The difference between clustered index and non-clustered index is: 1. Clustered index stores data rows in the index structure, which is suitable for querying by primary key and range. 2. The non-clustered index stores index key values ​​and pointers to data rows, and is suitable for non-primary key column queries.

MySQL: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

The relationship between mysql user and database The relationship between mysql user and database Apr 08, 2025 pm 07:15 PM

In MySQL database, the relationship between the user and the database is defined by permissions and tables. The user has a username and password to access the database. Permissions are granted through the GRANT command, while the table is created by the CREATE TABLE command. To establish a relationship between a user and a database, you need to create a database, create a user, and then grant permissions.

Can mysql and mariadb coexist Can mysql and mariadb coexist Apr 08, 2025 pm 02:27 PM

MySQL and MariaDB can coexist, but need to be configured with caution. The key is to allocate different port numbers and data directories to each database, and adjust parameters such as memory allocation and cache size. Connection pooling, application configuration, and version differences also need to be considered and need to be carefully tested and planned to avoid pitfalls. Running two databases simultaneously can cause performance problems in situations where resources are limited.

Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Explain different types of MySQL indexes (B-Tree, Hash, Full-text, Spatial). Apr 02, 2025 pm 07:05 PM

MySQL supports four index types: B-Tree, Hash, Full-text, and Spatial. 1.B-Tree index is suitable for equal value search, range query and sorting. 2. Hash index is suitable for equal value searches, but does not support range query and sorting. 3. Full-text index is used for full-text search and is suitable for processing large amounts of text data. 4. Spatial index is used for geospatial data query and is suitable for GIS applications.

See all articles