Big Data Learning Part 2 MYSQL Advanced
Article Directory
- 5 MySQL Architecture
- 5.1 MyISAM
- 5.2 Innodb
- 5.2.1 How to choose between system table space and independent table space
- 5.2.2 Features of Innodb storage engine
- 5.2.3 Innodb status check
- 5.2.4 Applicable scenarios
- 5.2.4 (Extended) What is a lock
- 5.2.3.1 What is a lock ?
- 5.2.3.2 Type of lock:
- 5.2.3.3 Compatibility relationship between write lock and read lock (compatibility for one row)
- 5.2.3.4 Lock granularity :
- 5.2.3.5 Blocking and deadlock
##5.3 CSV storage engine- ##5.3. 1 Characteristics of CSV storage engine
- 5.3.2 Applicable scenarios of CSV storage engine
- ##5.4 Archive storage engine
- ##5.4 .1 File system storage features
- 5.4.2 Archive storage engine features
- 5.4.3 Archive storage engine usage scenarios
- ##5.5 Memory storage engine
5.5.1 File system storage characteristics - 5.5.2 Functional characteristics of Memory
- 5.5.3 Easily confused concepts in Memory
- 5.5.4 Memory usage scenarios
- 5.6 Federated storage engine
5.6.1 Federated features- 5.6.2 How to use Federated
- 5.6.3 Applicable scenarios of Federated
- 6 How to choose the correct storage engine
Continued from the previous article
5 MySQL architecture
Next we select some of the more commonly used storage A brief explanation of the engine. The storage engine used by MySQL will have a direct impact on the performance of the database. I also hope that you can carefully understand some of the characteristics of the storage engine before using the storage engine.
5.1 MyISAM
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 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 through
check table tablename and restore the table through - repair 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 the - myisampack
command 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 - Applicable scenarios:
- Non-transactional applications
- 5.2 Innodb
-
Innodb is the default storage engine for MySQL 5.5 and later versions. Innodb is the storage engine for transaction 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 theinnodb_file_per_table
parameter. If this parameter isON
, A system file with the extensionibd
will be created for each Innodb table. If this parameter isOFF
, the data will be stored in the system's shared table space, that isibdataX
,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 pass optimize table
Command to shrink system fileswill 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 Methods in independent tablespaces.
Steps:
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
Read-only applications (Reports and the like)
- Spatial Application
- 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 Applicable scenarios
Innodb is suitable for most OLTP applications, because after mysql5.7 version, Innodb already supports full-text index and spatial functions.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)
Write lock |
Read lock | |
---|---|---|
Incompatible | Incompatible | |
Incompatible | Compatible |
The above is the detailed content of Big Data Learning Part 2 MYSQL Advanced. 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

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

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











The 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.

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Compared with other programming languages, MySQL is mainly used to store and manage data, while other languages such as Python, Java, and C are used for logical processing and application development. MySQL is known for its high performance, scalability and cross-platform support, suitable for data management needs, while other languages have advantages in their respective fields such as data analytics, enterprise applications, and system programming.

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

The basic operations of MySQL include creating databases, tables, and using SQL to perform CRUD operations on data. 1. Create a database: CREATEDATABASEmy_first_db; 2. Create a table: CREATETABLEbooks(idINTAUTO_INCREMENTPRIMARYKEY, titleVARCHAR(100)NOTNULL, authorVARCHAR(100)NOTNULL, published_yearINT); 3. Insert data: INSERTINTObooks(title, author, published_year)VA

When developing an e-commerce website using Thelia, I encountered a tricky problem: MySQL mode is not set properly, causing some features to not function properly. After some exploration, I found a module called TheliaMySQLModesChecker, which is able to automatically fix the MySQL pattern required by Thelia, completely solving my troubles.
