search
HomeDatabaseMysql TutorialMySQL database optimization (1)—MySQL engine

1. MySQL engine types
(1), InnoDB
1. Introduction to InnoDB
InnoDB is my default engine, supports transactions, and the data in is stored in the tablespace (tablespace). Prevent phantom reads through gap locking (next-key locking).
2. InnoDB Features
(1) In has done a lot of optimizations internally. In builds tables based on clustered indexes and has high performance for primary key queries.
(2) When reading data, a hash index can be created in the memory to speed up the insertion into the buffer, and read-ahead is used when reading data.
(3) Support hot backup, my other engines do not support this feature.
(2), MyISAM
1, Introduction to MyISAM
MyISAM is the default engine for versions prior to my5.1. It supports full-text indexing, compression, and spatial functions, but does not support transactions and row-level locks. It is suitable for applications that only support full-text indexing, compression, and spatial functions. Application scenarios where data is read and tables are small and can tolerate repair operations.
2. MyISAM features
(1) MyISAM storage stores tables in two files: data files and index files.
(2) MyISAM supports locking the entire table, but does not support row locking.
(3) MyISAM compressed table. For some table data that will no longer be modified, use MyISAM to compress the table to reduce disk I/O operations and improve query efficiency.
(3), CSV
The CSV engine can process ordinary CSV files as Mysql tables, and copy files in and out when the database is running. In addition, it can also dump excel and other format files into CSV, and then use Mysql The CSV engine processes it into mysql table type. As a data exchange mechanism, it is very practical.
(4), Memory
The Memory engine saves all data into the memory without disk I/O. The data it stores is mainly to save and search for intermediate data during data processing, and restart the data. Just clear it. If a temporary table is needed to save intermediate results during Mysql execution, the temporary table used internally is the Memory table.
(5) NDB Cluster
The NDB cluster index was developed by mysql after acquiring the NDB database. It supports distributed, disaster-tolerant, and high-availability database indexes.
2. Engine related operations
1. View the current version of mysql engine
Use the command show enginses; view the mysql engine
Mysql engine in version 5.1:

5.7 version The mysql engine in (can be viewed by executing the command on the mysql client):

2. Specify the mysql engine
Method 1: Modify the my.cnf configuration file

(1) If you are not sure where the my.cnf configuration file of mysql is stored, you can use sudo find /-name my.cnf to find the file path.

(2) is modified as follows:

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

default-storage-engine=MyISAM

( 3) Use the service mysqld start command to restart the mysql service; check the engine type

2. Specify the engine when creating the library/table
CREATE TABLE mytable (id int, title char(20)) ENGINE = INNODB
ALTER TABLE mytable ENGINE = MyISAM

The above is the content of MySQL database optimization (1) - MySQL engine. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


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
What are some tools you can use to monitor MySQL performance?What are some tools you can use to monitor MySQL performance?Apr 23, 2025 am 12:21 AM

How to effectively monitor MySQL performance? Use tools such as mysqladmin, SHOWGLOBALSTATUS, PerconaMonitoring and Management (PMM), and MySQL EnterpriseMonitor. 1. Use mysqladmin to view the number of connections. 2. Use SHOWGLOBALSTATUS to view the query number. 3.PMM provides detailed performance data and graphical interface. 4.MySQLEnterpriseMonitor provides rich monitoring functions and alarm mechanisms.

How does MySQL differ from SQL Server?How does MySQL differ from SQL Server?Apr 23, 2025 am 12:20 AM

The difference between MySQL and SQLServer is: 1) MySQL is open source and suitable for web and embedded systems, 2) SQLServer is a commercial product of Microsoft and is suitable for enterprise-level applications. There are significant differences between the two in storage engine, performance optimization and application scenarios. When choosing, you need to consider project size and future scalability.

In what scenarios might you choose SQL Server over MySQL?In what scenarios might you choose SQL Server over MySQL?Apr 23, 2025 am 12:20 AM

In enterprise-level application scenarios that require high availability, advanced security and good integration, SQLServer should be chosen instead of MySQL. 1) SQLServer provides enterprise-level features such as high availability and advanced security. 2) It is closely integrated with Microsoft ecosystems such as VisualStudio and PowerBI. 3) SQLServer performs excellent in performance optimization and supports memory-optimized tables and column storage indexes.

How does MySQL handle character sets and collations?How does MySQL handle character sets and collations?Apr 23, 2025 am 12:19 AM

MySQLmanagescharactersetsandcollationsbyusingUTF-8asthedefault,allowingconfigurationatdatabase,table,andcolumnlevels,andrequiringcarefulalignmenttoavoidmismatches.1)Setdefaultcharactersetandcollationforadatabase.2)Configurecharactersetandcollationfor

What are triggers in MySQL?What are triggers in MySQL?Apr 23, 2025 am 12:11 AM

A MySQL trigger is an automatically executed stored procedure associated with a table that is used to perform a series of operations when a specific data operation is performed. 1) Trigger definition and function: used for data verification, logging, etc. 2) Working principle: It is divided into BEFORE and AFTER, and supports row-level triggering. 3) Example of use: Can be used to record salary changes or update inventory. 4) Debugging skills: Use SHOWTRIGGERS and SHOWCREATETRIGGER commands. 5) Performance optimization: Avoid complex operations, use indexes, and manage transactions.

How do you create and manage user accounts in MySQL?How do you create and manage user accounts in MySQL?Apr 22, 2025 pm 06:05 PM

The steps to create and manage user accounts in MySQL are as follows: 1. Create a user: Use CREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password'; 2. Assign permissions: Use GRANTSELECT, INSERT, UPDATEONmydatabase.TO'newuser'@'localhost'; 3. Fix permission error: Use REVOKEALLPRIVILEGESONmydatabase.FROM'newuser'@'localhost'; then reassign permissions; 4. Optimization permissions: Use SHOWGRA

How does MySQL differ from Oracle?How does MySQL differ from Oracle?Apr 22, 2025 pm 05:57 PM

MySQL is suitable for rapid development and small and medium-sized applications, while Oracle is suitable for large enterprises and high availability needs. 1) MySQL is open source and easy to use, suitable for web applications and small and medium-sized enterprises. 2) Oracle is powerful and suitable for large enterprises and government agencies. 3) MySQL supports a variety of storage engines, and Oracle provides rich enterprise-level functions.

What are the disadvantages of using MySQL compared to other relational databases?What are the disadvantages of using MySQL compared to other relational databases?Apr 22, 2025 pm 05:49 PM

The disadvantages of MySQL compared to other relational databases include: 1. Performance issues: You may encounter bottlenecks when processing large-scale data, and PostgreSQL performs better in complex queries and big data processing. 2. Scalability: The horizontal scaling ability is not as good as Google Spanner and Amazon Aurora. 3. Functional limitations: Not as good as PostgreSQL and Oracle in advanced functions, some functions require more custom code and maintenance.

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

Video Face Swap

Video Face Swap

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

Hot Tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!