[MySQL] Detailed explanation of MySQL in one article, from basic concepts to tuning

About the Author

Preface:
The blogger has written a MySQL series before, from basic concepts and SQL to underlying principles and optimization. Column address:

https://blog.csdn.net/joker_zjn/category_12305262.html?spm=1001.2014.3001.5482

This article will be a list of this series, and we will talk about Mysql from basic concepts to optimization.

Table of contents

Table of contents

1. Basic concepts and SQL

2.SQL tuning

3. Optimize index

4. Some engineering issues


1. Basic concepts and SQL

Article link:

MySQL basic concepts and SQL__BugMan’s blog-CSDN blog

This part will talk about the basic concepts and SQL operations of MySQL, mainly including the following content:

  1. What is MySQL
  2. The difference between relational and non-relational databases
  3. MySQL architecture
  4. Some basic concepts of MySQL
  5. MySQL data types
  6. MySQL的SQL

1.What is MySQL

An open source, lightweight relational database that is widely used in the industry.

2. The difference between relational and non-relational databases

In fact, it is the difference in the way of data organization. The data in the relational database has strict format constraints, but there is no such restriction in the non-relational database.

3.MySQL architecture

The logical architecture of MySQL consists of three layers. One MySQL instance can have multiple libraries, one library can have multiple tables, and one table can have multiple fields.

4. Some basic concepts of MySQL

The main thing is to understand, what is the primary key? What is a foreign key? What is an index?

5.MySQL data types

MySQL has three major categories of data types: numerical values, strings, and date/time. Each of the three major types will include specific small types. For example, numerical values ​​will include BIGINT, FLOAT, DOUBLE, etc., and strings will include CHAR, VARCHAR et al.

6.SQL

The important content in SQL is mainly divided into two aspects:

  1. Operation sheets and libraries, including creation, deletion, structure adjustment, etc.
  2. Manipulate data, including adding, deleting, modifying, and querying data

2.SQL tuning

Article link:

Detailed explanation of MySQL index failure_mysql composite index failure__BugMan's blog-CSDN blog

When MySQL is used in an actual production environment, the speed of some original SQL queries will slow down after the amount of data accumulates to a certain level. At this time, it is necessary to tune the original SQL so that its speed can be restored. SQL tuning is also a core point of database optimization. The core of SQL tuning is actually to build a reasonable index and trade space for time.

This section contains:

  1. B-tree, B+ tree
  2. Under what circumstances will the index fail?

1.B tree, B+ tree

B-tree is a common self-balancing tree data structure that is widely used in applications such as database systems and file systems that require efficient insertion, deletion, and search operations. Because MySQL stores data on the disk, if there are many levels of search, it means that the mechanical movement of seek and magnetic head will occur many times, which is undoubtedly very time-consuming, so if there are few levels of search, there will be Very good efficiency. B-tree is a tree structure with few levels but capable of storing massive amounts of data. This article will give a detailed description of the data structure of the B-tree, the complete tree building process, and the capacity of storing data, as well as an introduction to the optimized structure of the B-tree, the B+ tree.

2. Under what circumstances will the index fail?

In fact, the fundamental reason why the index fails is that it violates the data structure of the B-tree, making accurate matching impossible. This article will give a detailed introduction to the following common index failure situations:

  • No index used
  • Violates the left prefix principle
  • Range query breaks index
  • like needs to be divided into different situations
  • As a result, more than half of the data

3. Optimize index

Article link:

Detailed explanation of MySQL covering index and index pushdown__BugMan's Blog-CSDN Blog

SQL tuning only involves building a suitable index, but sometimes the index mechanism itself also needs to be optimized. This section will talk about how to optimize the index mechanism, including:

  1. covering index
  2. index pushdown

1. Covering index

MySQL inherently has the problem of "querying back to the table". Covering the index is a method of using indexes to avoid "querying back to the table" and thereby reduce query time. The article will describe in detail what a "table return query" is and how to use covering indexes to solve the table return problem.

2. Index push down

Index pushdown is a new feature introduced since MySQL version 5.6. The purpose is to reduce "table return queries" and thereby improve the overall query efficiency. This article will discuss in detail what index pushdown is and how to solve the table return problem.

4. Some engineering issues

Article link:

How to reasonably generate primary keys in databases: UUID, Snowflake Algorithm_Primary Key Algorithm__BugMan's Blog-CSDN Blog

How to reasonably generate database primary keys is a problem in actual projects. First of all, in actual projects, we rarely use self-increasing primary keys such as 1, 2, 3... For example, if I want to synchronize data across databases, or synchronize data across "partitions" in a distributed system, no It's hard to imagine that 1, 2, 3... such increasing single numbers are extremely prone to conflicts. This article will introduce in detail some primary key generation algorithms, such as UUID, snowflake algorithm, etc.

Guess you like

Origin blog.csdn.net/Joker_ZJN/article/details/132779668