亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Home Database Mysql Tutorial what is mysql innodb

what is mysql innodb

Apr 14, 2023 am 10:19 AM
mysql innodb

InnoDB is one of the database engines of MySQL. It is now the default storage engine of MySQL and one of the standards for binary releases by MySQL AB. InnoDB adopts a dual-track authorization system, one is GPL authorization and the other is proprietary software authorization. . InnoDB is the preferred engine for transactional databases and supports transaction security tables (ACID); InnoDB supports row-level locks, which can support concurrency to the greatest extent. Row-level locks are implemented by the storage engine layer.

what is mysql innodb

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

If you want to see the storage engine used by your database by default, you can use the command SHOW VARIABLES LIKE 'storage_engine';

1. InnoDB storage engine

InnoDB is one of the database engines of MySQL. It is now the default storage engine of MySQL and one of the standards for binary releases by MySQL AB. InnoDB was developed by Innobase Oy and acquired by Oracle in May 2006. Compared with traditional ISAM and MyISAM, the biggest feature of InnoDB is that it supports ACID-compatible transaction (Transaction) function, similar to PostgreSQL.

InnoDB adopts a dual-track licensing system, one is GPL licensing and the other is proprietary software licensing.

1. InnoDB is the preferred engine for transactional databases and supports transaction security tables (ACID)

ACID attributes of transactions: That is, atomicity and consistency , Isolation, durability

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??????? been To roll back to the point where the transaction started.

This is implemented: is mainly based on the Redo and UNDO mechanism of MySQ log system. A transaction is a set of SQL statements that have functions such as selection, query, and deletion. There will be one node for each statement execution. For example, after the delete statement is executed, a record is saved in the transaction. This record stores when and what we did. If something goes wrong, it will be rolled back to the original position. What I have done has been stored in the redo, and then it can be executed in reverse.

## ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?? ?(eg: For example, if A transfers money to B, it is impossible that A deducts the money but B does not receive it)

## There is no interference between different transactions for the same data;


# ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?A transaction is modifying a certain data multiple times, and the multiple modifications in this transaction have not yet been committed. At this time, a concurrent transaction accesses the data, which will cause the data obtained by the two transactions to be inconsistent); (read Fetched uncommitted dirty data from another transaction)

## ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Data, multiple queries within a transaction range returned different data values. This is because it was modified and submitted by another transaction during the query interval; (the data submitted by the previous transaction was read, and the same data values ??were queried. A data item)

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Virtual read (phantom read) : It is a phenomenon that occurs when transactions are not executed independently (eg: transaction T1 reads all rows in a table A data item was modified from "1" to "2". At this time, transaction T2 inserted a row of data items into the table, and the value of this data item was still "1" and submitted to the database. If the user operating transaction T1 looks at the data that was just modified, he will find that there is still one row that has not been modified. In fact, this row was added from transaction T2, as if he was hallucinating. ; : After the transaction is completed, all updates to the database by the transaction will be saved to the database and cannot be rolled back 2. InnoDB is the default storage engine of mySQL. The default isolation level is RR, and in RR Taking the isolation level a step further, multi-version concurrency control (MVCC) is used to solve the non-repeatable read problem, and gap locks (that is, concurrency control) are added to solve the phantom read problem. Therefore, InnoDB's RR isolation level actually achieves the effect of serialization level while retaining better concurrency performance. MySQL database provides us with four isolation levels: a, Serializable (serialization): can avoid dirty reads, non-repeatable reads, and phantom reads occurs; b, Repeatable read (repeatable read): can avoid the occurrence of dirty reads and non-repeatable reads;

c, Read committed (read committed): can avoid the occurrence of dirty reads Occurrence;

d, Read uncommitted (read uncommitted): the lowest level, no guarantee in any situation;

from a----d isolation level from high to low, the higher the level , the lower the execution efficiency

3. InnoDB supports row-level locks. Row-level locks can support concurrency to the greatest extent, and row-level locks are implemented by the storage engine layer.

Lock

: The main function of the lock is to manage concurrent access to shared resources and is used to achieve transaction isolation

????????

Type:

Shared lock (read lock), exclusive lock (write lock)

## MySQL Lock strength

: table-level locks (low overhead, low concurrency), usually implemented at the server layer ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? but ? ? ?, will only be implemented at the storage engine level4. InnoDB is designed for maximum performance in processing huge amounts of data. Its CPU efficiency may be unmatched by any disk-based relational database engine

5. The InnoDB storage engine is fully integrated with the MySQL server. The InnoDB storage engine is cached in the main memory. It maintains its own buffer pool for data and indexes. InnoDB places its tables and indexes in a logical table space. The table space can contain several files (or original disk files); 6. InnoDB supports foreign key integrity constraints. When storing data in a table, each table is stored in the order of the primary key. If the primary key is not specified when the table is defined. InnoDB will generate a 6-byte ROWID for each row and use it as the primary key


7. InnoDB is used in many large database sites that require high performance

8. InnoDB does not save the number of rows in the table (eg: when selecting count(*) from table, InnoDB needs to scan the entire table to calculate how many rows there are); when clearing the entire table, InnoDB stores one row Deletion of one row is very slow;

InnoDB does not create a directory. When using InnoDB, MySQL will create a 10MB automatically extended data file named ibdata1 in the MySQL data directory. And two 5MB log files named ib_logfile0 and ib_logfile1

2. The underlying implementation of the InnoDB engine

InnoDB has two storage files, the suffixes are .frm and .idb; .frm is the definition file of the table, and .idb is the data file of the table.

1. The InnoDB engine uses the B Tree structure as the index structure

B-Tree (balanced multi-path search tree): for disks, etc. A balanced search tree designed for external storage devices

When the system reads data from disk to memory, the basic unit is disk block bits. Data located in the same disk block will be read once read out on a regular basis, rather than on demand.

InnoDB storage engine uses pages as data reading units. Pages are the smallest unit of disk management. The default page size is 16k.

The storage space of a disk block in the system is often not that large, so every time InnoDB applies for disk space, it will use several consecutive disk blocks with addresses to reach the page size of 16KB.

InnoDB will use pages as the basic unit when reading disk data into the disk. When querying data, if each piece of data in a page can help locate the data record location, which will reduce the number of disk I/O and improve query efficiency.

The data in the B-Tree structure allows the system to efficiently find the disk block where the data is located

Each node in the B-Tree is based on The actual situation can contain a large amount of keyword information and branches, for example:

what is mysql innodb

Each node occupies one disk block Space, there are two ascending-order keys on a node and three pointers to the root node of the subtree. The pointers store the address of the disk block where the child node is located.

Take the root node as an example. The keywords are 17 and 35. The data range of the subtree pointed to by the P1 pointer is less than 17. The P2 pointerThe data range of the subtree pointed to is 17----35, and the data range of the subtree pointed to by the P3 pointer is greater than 35;

Simulated searchKeywords Process 29:

a. Find disk block 1 based on the root node and read it into memory. [The first disk I/O operation]

b. Compare keyword 29 in the interval (17,35) and find the pointer P2 of disk block 1;

c. Find disk block 3 according to the P2 pointer and read it into the memory. [Disk I/O operation for the second time]

d. Compare keyword 29 in the interval (26, 30) and find pointer P2 of disk block 3;

e. Find disk block 8 according to the P2 pointer and read it into the memory. [Disk I/O operation third time]

f. Keyword 29 was found in the keyword list in disk block 8.

MySQL's InnoDB storage engine is designed with the root node resident in memory, so it strives to achieve a tree depth of no more than 3, that is, I/O does not need to exceed three times;

Analyzing the above results, we found that three disk I/O operations and three memory search operations are required. Since the keywords in the memory are an ordered list structure, binary search can be used to improve efficiency; three disk I/O operations are the decisive factor affecting the entire B-Tree search efficiency.

B Tree

B Tree is an optimization based on B-Tree, making it more suitable Implement the external storage index structure. Each node in B-Tree has key and data, and the storage space of each page is limited. If the data data is large, each node (i.e. one page) will be able to store The number of keys is very small. When the amount of data stored is large, the depth of the B-Tree will also be larger, which will increase the number of disk I/Os during query, thus affecting query efficiency.

In B Tree, all data record nodes are stored on leaf nodes of the same layer in order of key value. Only key value information is stored on non-leaf nodes. This can greatly Increase the number of key values ??stored in each node and reduce the height of B Tree;

B Tree has two changes based on B-Tree: ( 1) The data is stored in leaf nodes

Since the non-leaf nodes of B Tree only store key value information, assuming that each disk block can store 4 key values ??and pointer information, the structure after becoming B Tree is as shown below:

what is mysql innodb

Usually there are two head pointers on the B Tree, one points to the root node, the other points to the leaf node with the smallest keyword, and There is a chain ring structure between all leaf nodes (ie data nodes).

Therefore, two search operations can be performed on B Tree, one is a range search and paging search for the primary key, and the other is a random search starting from the root node.

B Tree in InnoDB

InnoDB is a data storage indexed by ID

There are two data storage files using the InnoDB engine, one is a definition file and the other is a data file.

InnoDB builds an index on the ID through the B Tree structure, and then stores the records in the leaf nodes

what is mysql innodb

##If the indexed field is not the primary key ID, create an index for the field, then store the primary key of the record in the leaf node, and then find the corresponding record through the primary key index

[Related recommendations:

mysql video tutorial]

The above is the detailed content of what is mysql innodb. For more information, please follow other related articles on the PHP Chinese website!

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

Undress AI Tool

Undress AI Tool

Undress images for free

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.

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)

Hot Topics

PHP Tutorial
1488
72
How to use PHP to develop a Q&A community platform Detailed explanation of PHP interactive community monetization model How to use PHP to develop a Q&A community platform Detailed explanation of PHP interactive community monetization model Jul 23, 2025 pm 07:21 PM

1. The first choice for the Laravel MySQL Vue/React combination in the PHP development question and answer community is the first choice for Laravel MySQL Vue/React combination, due to its maturity in the ecosystem and high development efficiency; 2. High performance requires dependence on cache (Redis), database optimization, CDN and asynchronous queues; 3. Security must be done with input filtering, CSRF protection, HTTPS, password encryption and permission control; 4. Money optional advertising, member subscription, rewards, commissions, knowledge payment and other models, the core is to match community tone and user needs.

How to set environment variables in PHP environment Description of adding PHP running environment variables How to set environment variables in PHP environment Description of adding PHP running environment variables Jul 25, 2025 pm 08:33 PM

There are three main ways to set environment variables in PHP: 1. Global configuration through php.ini; 2. Passed through a web server (such as SetEnv of Apache or fastcgi_param of Nginx); 3. Use putenv() function in PHP scripts. Among them, php.ini is suitable for global and infrequently changing configurations, web server configuration is suitable for scenarios that need to be isolated, and putenv() is suitable for temporary variables. Persistence policies include configuration files (such as php.ini or web server configuration), .env files are loaded with dotenv library, and dynamic injection of variables in CI/CD processes. Security management sensitive information should be avoided hard-coded, and it is recommended to use.en

Automating MySQL Deployments with Infrastructure as Code Automating MySQL Deployments with Infrastructure as Code Jul 20, 2025 am 01:49 AM

To achieve MySQL deployment automation, the key is to use Terraform to define resources, Ansible management configuration, Git for version control, and strengthen security and permission management. 1. Use Terraform to define MySQL instances, such as the version, type, access control and other resource attributes of AWSRDS; 2. Use AnsiblePlaybook to realize detailed configurations such as database user creation, permission settings, etc.; 3. All configuration files are included in Git management, support change tracking and collaborative development; 4. Avoid hard-coded sensitive information, use Vault or AnsibleVault to manage passwords, and set access control and minimum permission principles.

How to use PHP to develop product recommendation module PHP recommendation algorithm and user behavior analysis How to use PHP to develop product recommendation module PHP recommendation algorithm and user behavior analysis Jul 23, 2025 pm 07:00 PM

To collect user behavior data, you need to record browsing, search, purchase and other information into the database through PHP, and clean and analyze it to explore interest preferences; 2. The selection of recommendation algorithms should be determined based on data characteristics: based on content, collaborative filtering, rules or mixed recommendations; 3. Collaborative filtering can be implemented in PHP to calculate user cosine similarity, select K nearest neighbors, weighted prediction scores and recommend high-scoring products; 4. Performance evaluation uses accuracy, recall, F1 value and CTR, conversion rate and verify the effect through A/B tests; 5. Cold start problems can be alleviated through product attributes, user registration information, popular recommendations and expert evaluations; 6. Performance optimization methods include cached recommendation results, asynchronous processing, distributed computing and SQL query optimization, thereby improving recommendation efficiency and user experience.

mysql revoke privileges from user mysql revoke privileges from user Jul 16, 2025 am 03:56 AM

To recycle MySQL user permissions using REVOKE, you need to specify the permission type, database, and user by format. 1. Use REVOKEALLPRIVILEGES, GRANTOPTIONFROM'username'@'hostname'; 2. Use REVOKEALLPRIVILEGESONmydb.FROM'username'@'hostname'; 3. Use REVOKEALLPRIVILEGESONmydb.FROM'username'@'hostname'; 3. Use REVOKE permission type ON.*FROM'username'@'hostname'; Note that after execution, it is recommended to refresh the permissions. The scope of the permissions must be consistent with the authorization time, and non-existent permissions cannot be recycled.

How to build an online customer service robot with PHP. PHP intelligent customer service implementation technology How to build an online customer service robot with PHP. PHP intelligent customer service implementation technology Jul 25, 2025 pm 06:57 PM

PHP plays the role of connector and brain center in intelligent customer service, responsible for connecting front-end input, database storage and external AI services; 2. When implementing it, it is necessary to build a multi-layer architecture: the front-end receives user messages, the PHP back-end preprocesses and routes requests, first matches the local knowledge base, and misses, call external AI services such as OpenAI or Dialogflow to obtain intelligent reply; 3. Session management is written to MySQL and other databases by PHP to ensure context continuity; 4. Integrated AI services need to use Guzzle to send HTTP requests, safely store APIKeys, and do a good job of error handling and response analysis; 5. Database design must include sessions, messages, knowledge bases, and user tables, reasonably build indexes, ensure security and performance, and support robot memory

Securing MySQL Connections with SSL/TLS Encryption Securing MySQL Connections with SSL/TLS Encryption Jul 21, 2025 am 02:08 AM

Why do I need SSL/TLS encryption MySQL connection? Because unencrypted connections may cause sensitive data to be intercepted, enabling SSL/TLS can prevent man-in-the-middle attacks and meet compliance requirements; 2. How to configure SSL/TLS for MySQL? You need to generate a certificate and a private key, modify the configuration file to specify the ssl-ca, ssl-cert and ssl-key paths and restart the service; 3. How to force SSL when the client connects? Implemented by specifying REQUIRESSL or REQUIREX509 when creating a user; 4. Details that are easily overlooked in SSL configuration include certificate path permissions, certificate expiration issues, and client configuration requirements.

How to develop AI intelligent form system with PHP PHP intelligent form design and analysis How to develop AI intelligent form system with PHP PHP intelligent form design and analysis Jul 25, 2025 pm 05:54 PM

When choosing a suitable PHP framework, you need to consider comprehensively according to project needs: Laravel is suitable for rapid development and provides EloquentORM and Blade template engines, which are convenient for database operation and dynamic form rendering; Symfony is more flexible and suitable for complex systems; CodeIgniter is lightweight and suitable for simple applications with high performance requirements. 2. To ensure the accuracy of AI models, we need to start with high-quality data training, reasonable selection of evaluation indicators (such as accuracy, recall, F1 value), regular performance evaluation and model tuning, and ensure code quality through unit testing and integration testing, while continuously monitoring the input data to prevent data drift. 3. Many measures are required to protect user privacy: encrypt and store sensitive data (such as AES

See all articles