
Free learning recommendation: mysql video tutorial
5 MySQL architecture

Below we select some of the more commonly used storage engines for a brief explanation. The storage engine used by mysql will have a direct impact on the performance of the database. I hope you can carefully Understand some of the characteristics of the storage engine, and only use the storage engine after that.
5.1 MyISAM
MyISAM was the default storage engine before MySQL5.5. For this reason, there are still many servers using the MyISAM storage engine. At the same time, MyISAM is currently the storage engine used by many system tables and temporary tables. The temporary table mentioned here is not the table we create through create table, but refers to the amount of data used during operations such as sorting and grouping. After exceeding a certain size, there are temporary tables created by the query optimizer.
The MyISAM storage engine is composed of MYD and MYI. MYD is the extension of the data file and MYI is the extension of the index file. This storage engine stores tables in data files and index files with these two extensions. middle.
Features:
- Concurrency and lock level
MyISAM uses table-level locks, not row-level locks, which means that the data in the table is When modifying, the entire table needs to be locked, and when reading the table, shared locks are also added to all tables. From here we can see that the table reading and writing operations using MyISAM as the engine are Mutually exclusive. It can be seen that MyISAM is not very good at concurrent reading and writing operations. If it is only for read-only operations, the performance is not bad in terms of concurrency because the shared lock does not block the shared lock. - Table damage repair
MyISAM supports checking and repairing MyISAM tables that are damaged due to any unexpected shutdown, but the repair mentioned here is not data recovery, because MyISAM is not transactional storage engine, so it cannot perform related logs required for transaction recovery, so be aware that the recovery of MyISAM tables may cause data loss.
We can check the table throughcheck table tablenameand restore the table throughrepair table tablename. - Index types supported by MyISAM tables
MyISAM supports full-text indexing, and was the only official storage engine that natively supported full-text indexing before mysql5.7. - MyISAM table supports data compression
If MyISAM represents a large read-only table, that is, after the table is created and the data is imported, no modifications will be made to the table, then we will Tables can be compressed to reduce disk I/O. We can use themyisampackcommand to compress the table. Compression compresses the table independently, so when reading a row of data, it is not necessary to decompress the entire table.
Restrictions:
- Version
- If you store a large table, you need to modify MAX_Rows and AVG_ROW_LENGTH
- Version> The default support for mysql5.0 is 256TB
Applicable scenarios:
- Non-transactional applications
- Read-only applications (Reports and the like)
- Spatial Application
5.2 Innodb
Innodb is the default storage engine for MySQL5.5 and later versions. Innodb is a storage engine for transactional storage, which means it supports transaction processing.
Innodb has its own concept of table space, and the data is stored in the table space, which is determined by the innodb_file_per_table parameter. If this parameter is ON, A system file with the extension ibd will be created for each Innodb table. If this parameter is OFF, the data will be stored in the system's shared table space, that is ibdataX, X represents a number, starting from 1 by default.
The command to view this parameter is: show variables like 'innodb_file_per_table';
The command to modify this parameter is: set global innodb_file_per_table=off;
5.2.1 How to choose between system table space and independent table space
Comparison:
| System table space | Independent table space |
|---|---|
| Cannot simply shrink the file size | You can passoptimize tableCommand to shrink system files |
| will cause IO bottleneck | Can refresh data to multiple files at the same time |
Recommendation:
- Use independent table space for Innodb
Transfer the table that originally existed in the system table space to an independent table space method in.
Steps:
- Use mysqldump to export all database table data
- Stop the MySQL service, modify parameters, and delete Innodb related files
- Restart the MySQL service and rebuild the Innodb system table space
- Reimport the data
##5.2.2 Features of the Innodb storage engine
- Innodb is a transactional storage engine
- Fully supports the ACID characteristics of transactions (the atomicity, consistency, etc. introduced before)
- Redo Log and Undo Log
- Redo Log implementation The durability of the transaction is composed of two parts, one of which is the work log persistent buffer in memory, whose size is determined by innodb_log_buffer_size, and the other is the reconstructed log file, which is the ib_logflie we see in the file system related documents. Undo Log realizes the atomicity of transactions and performs rollback operations when transactions fail. Redo Log is read and written sequentially, and Undo Log is read and written randomly. If possible, the data can be stored in a solid-state drive to improve performance.
Innodb supports row-level locks - Row-level locks and table-level locks are different. The characteristic of row-level locks is that they can support concurrency to the greatest extent. Row-level locks are implemented by the storage engine layer.
5.2.3 Innodb status check
You can use the following command to check the Innodb status:
show engine innodb status
5.2.4 (Extended) What is a lock
5.2.3.1 What is a lock?- The main function of locks is to manage concurrent access to shared resources
- Locks are used to achieve transaction isolation
- Shared lock (also called read lock)
- Exclusive lock (also called write lock)
| Read lock | ||
|---|---|---|
| Incompatible | Incompatible | |
| No Compatible | Compatible |
The above is the detailed content of The second article introducing advanced MYSQL. For more information, please follow other related articles on the PHP Chinese website!
MySQL's Role: Databases in Web ApplicationsApr 17, 2025 am 12:23 AMThe main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.
MySQL: Building Your First DatabaseApr 17, 2025 am 12:22 AMThe steps to build a MySQL database include: 1. Create a database and table, 2. Insert data, and 3. Conduct queries. First, use the CREATEDATABASE and CREATETABLE statements to create the database and table, then use the INSERTINTO statement to insert the data, and finally use the SELECT statement to query the data.
MySQL: A Beginner-Friendly Approach to Data StorageApr 17, 2025 am 12:21 AMMySQL is suitable for beginners because it is easy to use and powerful. 1.MySQL is a relational database, and uses SQL for CRUD operations. 2. It is simple to install and requires the root user password to be configured. 3. Use INSERT, UPDATE, DELETE, and SELECT to perform data operations. 4. ORDERBY, WHERE and JOIN can be used for complex queries. 5. Debugging requires checking the syntax and use EXPLAIN to analyze the query. 6. Optimization suggestions include using indexes, choosing the right data type and good programming habits.
Is MySQL Beginner-Friendly? Assessing the Learning CurveApr 17, 2025 am 12:19 AMMySQL is suitable for beginners because: 1) easy to install and configure, 2) rich learning resources, 3) intuitive SQL syntax, 4) powerful tool support. Nevertheless, beginners need to overcome challenges such as database design, query optimization, security management, and data backup.
Is SQL a Programming Language? Clarifying the TerminologyApr 17, 2025 am 12:17 AMYes,SQLisaprogramminglanguagespecializedfordatamanagement.1)It'sdeclarative,focusingonwhattoachieveratherthanhow.2)SQLisessentialforquerying,inserting,updating,anddeletingdatainrelationaldatabases.3)Whileuser-friendly,itrequiresoptimizationtoavoidper
Explain the ACID properties (Atomicity, Consistency, Isolation, Durability).Apr 16, 2025 am 12:20 AMACID attributes include atomicity, consistency, isolation and durability, and are the cornerstone of database design. 1. Atomicity ensures that the transaction is either completely successful or completely failed. 2. Consistency ensures that the database remains consistent before and after a transaction. 3. Isolation ensures that transactions do not interfere with each other. 4. Persistence ensures that data is permanently saved after transaction submission.
MySQL: Database Management System vs. Programming LanguageApr 16, 2025 am 12:19 AMMySQL is not only a database management system (DBMS) but also closely related to programming languages. 1) As a DBMS, MySQL is used to store, organize and retrieve data, and optimizing indexes can improve query performance. 2) Combining SQL with programming languages, embedded in Python, using ORM tools such as SQLAlchemy can simplify operations. 3) Performance optimization includes indexing, querying, caching, library and table division and transaction management.
MySQL: Managing Data with SQL CommandsApr 16, 2025 am 12:19 AMMySQL uses SQL commands to manage data. 1. Basic commands include SELECT, INSERT, UPDATE and DELETE. 2. Advanced usage involves JOIN, subquery and aggregate functions. 3. Common errors include syntax, logic and performance issues. 4. Optimization tips include using indexes, avoiding SELECT* and using LIMIT.


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

SublimeText3 English version
Recommended: Win version, supports code prompts!

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function









