search
HomeBackend DevelopmentPHP TutorialWhat is the difference between mySQL's MyISAM and InnoDB? How to optimize MYSQL database?

Basic differences between MyISAM and InnoDB

1. InnoDB does not support FULLTEXT type indexes.

2. InnoDB does not save the specific number of rows in the table. That is to say, when executing select count(*) from table, InnoDB has to scan the entire table to calculate how many rows there are, but MyISAM simply reads and saves it. A good number of lines is enough. Note that when the count(*) statement contains a where condition, the operations of the two tables are the same.

3. For fields of type AUTO_INCREMENT, InnoDB must contain an index with only this field, but in the MyISAM table, a joint index can be established with other fields.

4. When DELETE FROM table, InnoDB will not re-create the table, but will delete it row by row. MyISAM is the table that innodb has row locks

5. The LOAD TABLE FROM MASTER (from the main load table) operation does not work for InnoDB. The solution is to first change the InnoDB table to a MyISAM table, and then change it after importing the data. into an InnoDB table, but does not apply to tables that use additional InnoDB features (such as foreign keys).

In addition, the row lock of the InnoDB table is not absolute. If MySQL cannot determine the range to be scanned when executing a SQL statement, the InnoDB table will also lock the entire table, for example, update table set num=1 where name like " "2%"

6.InnoDB supports things

Select the storage engine according to the actual situation

Generally, it is recommended to use myIsam if you have multiple queries.

If you need transaction processing or Foreign keys, then InnoDB may be a better way.

Methods to optimize MYSQL database:

1. Select the most applicable field attributes, reduce the length of the defined field as much as possible, and try to set the field to NOT NULL, for example. 'Province, Gender', it is best to set it to ENUM

2, use join instead of subquery

3, use union (UNION) instead of manually created temporary table

4, transaction processing (guaranteed Data integrity, such as adding and modifying at the same time, if both are true, both will be executed, if one fails, both will fail)

5, Proper indexing (how to create an index? What are the pros and cons of indexing?)

6, Optimize sql statement

7, explain you can see the mysql execution plan

8, sub-table (vertical sub-table, horizontal sub-table?)

Related reading

http://www. phpernote.com/mysql/500.html

http://www.nowamagic.net/librarys/veda/detail/1899

The above introduces the difference between MyISAM and InnoDB of mysql? How to optimize MYSQL database? , including relevant content, I hope it will be helpful to friends who are interested in PHP tutorials.

Statement
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
counta和count的区别counta和count的区别Nov 20, 2023 am 10:01 AM

Count函数用于计算指定范围内数字的个数。它忽略文本、逻辑值和空值,但会将空单元格计算在内,Count函数只计算包含实际数字的单元格数量。而CountA函数用于计算指定范围内非空单元格的个数。它不仅计算包含实际数字的单元格,还计算包含文本、逻辑值和公式等非空单元格的数量。

mysql innodb是什么mysql innodb是什么Apr 14, 2023 am 10:19 AM

InnoDB是MySQL的数据库引擎之一,现为MySQL的默认存储引擎,为MySQL AB发布binary的标准之一;InnoDB采用双轨制授权,一个是GPL授权,另一个是专有软件授权。InnoDB是事务型数据库的首选引擎,支持事务安全表(ACID);InnoDB支持行级锁,行级锁可以最大程度的支持并发,行级锁是由存储引擎层实现的。

MySQL如何从二进制内容看InnoDB行格式MySQL如何从二进制内容看InnoDB行格式Jun 03, 2023 am 09:55 AM

InnoDB是一个将表中的数据存储到磁盘上的存储引擎,所以即使关机后重启我们的数据还是存在的。而真正处理数据的过程是发生在内存中的,所以需要把磁盘中的数据加载到内存中,如果是处理写入或修改请求的话,还需要把内存中的内容刷新到磁盘上。而我们知道读写磁盘的速度非常慢,和内存读写差了几个数量级,所以当我们想从表中获取某些记录时,InnoDB存储引擎需要一条一条的把记录从磁盘上读出来么?InnoDB采取的方式是:将数据划分为若干个页,以页作为磁盘和内存之间交互的基本单位,InnoDB中页的大小一般为16

Mysql中的innoDB怎么解决幻读Mysql中的innoDB怎么解决幻读May 27, 2023 pm 03:34 PM

1.Mysql的事务隔离级别这四种隔离级别,当存在多个事务并发冲突的时候,可能会出现脏读,不可重复读,幻读的一些问题,而innoDB在可重复读隔离级别模式下解决了幻读的一个问题,2.什么是幻读幻读是指在同一个事务中,前后两次查询相同范围的时候得到的结果不一致如图,第一个事务里面,我们执行一个范围查询,这个时候满足条件的数据只有一条,而在第二个事务里面,它插入一行数据并且进行了提交,接着第一个事务再去查询的时候,得到的结果比第一次查询的结果多出来一条数据,注意第一个事务的第一次和第二次查询,都在同

mysql innodb异常怎么处理mysql innodb异常怎么处理Apr 17, 2023 pm 09:01 PM

一、回退重新装mysql为避免再从其他地方导入这个数据的麻烦,先对当前库的数据库文件做了个备份(/var/lib/mysql/位置)。接下来将Perconaserver5.7包进行了卸载,重新安装原先老的5.1.71的包,启动mysql服务,提示Unknown/unsupportedtabletype:innodb,无法正常启动。11050912:04:27InnoDB:Initializingbufferpool,size=384.0M11050912:04:27InnoDB:Complete

MySQL储存引擎选型对比:InnoDB、MyISAM与Memory性能指标评估MySQL储存引擎选型对比:InnoDB、MyISAM与Memory性能指标评估Jul 26, 2023 am 11:25 AM

MySQL储存引擎选型对比:InnoDB、MyISAM与Memory性能指标评估引言:在MySQL数据库中,储存引擎的选择对于系统性能和数据完整性起着至关重要的作用。MySQL提供了多种储存引擎,其中最常用的引擎包括InnoDB、MyISAM和Memory。本文将就这三种储存引擎进行性能指标评估,并通过代码示例进行比较。一、InnoDB引擎InnoDB是My

如何使用MyISAM和InnoDB存储引擎来优化MySQL性能如何使用MyISAM和InnoDB存储引擎来优化MySQL性能May 11, 2023 pm 06:51 PM

MySQL是一款广泛使用的数据库管理系统,不同的存储引擎对数据库性能有不同的影响。MyISAM和InnoDB是MySQL中最常用的两种存储引擎,它们的特点各有不同,使用不当可能会影响数据库的性能。本文将介绍如何使用这两种存储引擎来优化MySQL性能。一、MyISAM存储引擎MyISAM是MySQL最常用的存储引擎,它的优点是速度快,存储占用空间小。MyISA

提高MySQL存储引擎读取性能的技巧和策略:MyISAM与InnoDB对比分析提高MySQL存储引擎读取性能的技巧和策略:MyISAM与InnoDB对比分析Jul 26, 2023 am 10:01 AM

提高MySQL存储引擎读取性能的技巧和策略:MyISAM与InnoDB对比分析引言:MySQL是最常用的开源关系型数据库管理系统之一,主要用于存储和管理大量结构化数据。在应用中,对于数据库的读取性能往往是非常重要的,因为读取操作是大部分应用的主要操作类型。本文将重点讨论如何提高MySQL存储引擎的读取性能,重点对比分析MyISAM和InnoDB这两个常用的存

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),