Detailed explanation of the storage engine of mysql database
This article talks about the storage engine of mysql database, so students who don’t know much about the storage engine of mysql database and our engine should take a look at this article about the storage engine of mysql database!
Optimization structure introduction:
Type | Meaning |
---|---|
Storage layer | Storage engine, field type selection, paradigm design |
Design layer | Index, cache, partition ( Sub-table) |
ArchitectureLayer | Multiple mysql server settings, read and write separation (master-slave mode) |
sql statement layer | When multiple sql statements can achieve the purpose, you must choose a sql statement with high performance and fast speed |
Storage Engine
Storage engine: The data we use is stored in the database through certain technologies. The database data is stored in the hard disk in the form of files. There is more than one technology, and each technology has its own unique performance and functionality. The combination of technology and functionality for storing data is called a "storage engine."
Storage engines often used in mysql:
Myisam
orInnodb
, etc.-
Database data is stored in different storage engines, and all features are related to the current storage engine. Different storage engines need to be selected according to the needs and characteristics of the project.
View all storage engines supported in mysql:
innodb
Database Three aspects of data design information for each data table: table structure, data, index
Technical features: support transactions, row-level locking, foreign keys
Physical storage of table structure, data, and indexes
Create an innodb data table:
Table structure file:
Physical file location of this type of data and index:
The data and index information of all innodb tables are stored in the following ibdata1 file
For innodb type tables The data and indexes create their own corresponding storage space:
By default, the data and indexes of each innodb table will not create separate file storage
Set variables so that each innodb table has unique data and index storage files:
Re-create the order2 data table:
- # #At this time, the order2 data table has separate data and index storage files:
- ##No matter how the setting status of innodb_file_per_table changes later , the data and index of order2 have independent storage locations
- Data storage order
- Innodb table data is stored according to the primary key Arrange each written data in order.
This feature determines that the write operation of this type of table is slow.
Transactions and foreign keys
This type of data table supports transactions and foreign keys
- Transactions: http://blog.csdn.net/change_any_time /article/details/79488020
- Foreign key: Two data tables A and B. The primary key of table B is an ordinary field of table A. When you look at this ordinary field in table A, it is the The "foreign key" of the table, the use of foreign key has "constraints".
- "Foreign keys" are rarely used in real projects because of constraints.
- Concurrency
The concurrency of this type of table is very high. Multiple people operate the data table at the same time. In order to operate the data table, the data content will not happen randomly. Changes require "locking" information
The lock level of this type is: row lock. Only the current record being operated on is locked.Myisam
The structure, data, and indexes are stored independently. This type of data table has independent storage files for the table structure, data, and indexes:
Create Myisam Data table
The structure, data, and index of each myisam data table have independent storage files
Table file type | Meaning |
---|---|
Table structure file | |
Table data file | |
Table index file |
The above is the detailed content of Detailed explanation of the storage engine of mysql database. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

MySQL query performance can be optimized by building indexes that reduce lookup time from linear complexity to logarithmic complexity. Use PreparedStatements to prevent SQL injection and improve query performance. Limit query results and reduce the amount of data processed by the server. Optimize join queries, including using appropriate join types, creating indexes, and considering using subqueries. Analyze queries to identify bottlenecks; use caching to reduce database load; optimize PHP code to minimize overhead.

Backing up and restoring a MySQL database in PHP can be achieved by following these steps: Back up the database: Use the mysqldump command to dump the database into a SQL file. Restore database: Use the mysql command to restore the database from SQL files.

How to insert data into MySQL table? Connect to the database: Use mysqli to establish a connection to the database. Prepare the SQL query: Write an INSERT statement to specify the columns and values to be inserted. Execute query: Use the query() method to execute the insertion query. If successful, a confirmation message will be output.

One of the major changes introduced in MySQL 8.4 (the latest LTS release as of 2024) is that the "MySQL Native Password" plugin is no longer enabled by default. Further, MySQL 9.0 removes this plugin completely. This change affects PHP and other app

To use MySQL stored procedures in PHP: Use PDO or the MySQLi extension to connect to a MySQL database. Prepare the statement to call the stored procedure. Execute the stored procedure. Process the result set (if the stored procedure returns results). Close the database connection.

Creating a MySQL table using PHP requires the following steps: Connect to the database. Create the database if it does not exist. Select a database. Create table. Execute the query. Close the connection.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps
