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

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 is suitable for beginners because it is simple to install, powerful and easy to manage data. 1. Simple installation and configuration, suitable for a variety of operating systems. 2. Support basic operations such as creating databases and tables, inserting, querying, updating and deleting data. 3. Provide advanced functions such as JOIN operations and subqueries. 4. Performance can be improved through indexing, query optimization and table partitioning. 5. Support backup, recovery and security measures to ensure data security and consistency.

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

Create a database using Navicat Premium: Connect to the database server and enter the connection parameters. Right-click on the server and select Create Database. Enter the name of the new database and the specified character set and collation. Connect to the new database and create the table in the Object Browser. Right-click on the table and select Insert Data to insert the data.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

You can create a new MySQL connection in Navicat by following the steps: Open the application and select New Connection (Ctrl N). Select "MySQL" as the connection type. Enter the hostname/IP address, port, username, and password. (Optional) Configure advanced options. Save the connection and enter the connection name.

Recovering deleted rows directly from the database is usually impossible unless there is a backup or transaction rollback mechanism. Key point: Transaction rollback: Execute ROLLBACK before the transaction is committed to recover data. Backup: Regular backup of the database can be used to quickly restore data. Database snapshot: You can create a read-only copy of the database and restore the data after the data is deleted accidentally. Use DELETE statement with caution: Check the conditions carefully to avoid accidentally deleting data. Use the WHERE clause: explicitly specify the data to be deleted. Use the test environment: Test before performing a DELETE operation.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.
