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!

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc


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

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.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

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

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

SublimeText3 Linux new version
SublimeText3 Linux latest version
