Explanation of MySQL's horizontal and vertical table partitioning

Explanation of MySQL's horizontal and vertical table partitioning

In my previous article, I said that the optimization of MySQL statements has limitations. The optimization of MySQL statements revolves around index optimization. If the index in MySQL cannot solve the problem of slow query of massive data, then horizontal and vertical table partitioning will appear (I just record my understanding)

Horizontal table:

As shown in the figure above: The other three tables have the same structure, except that the data is stored separately in these three tables. If you want to insert or query, you need to take the modulus of the id and then concatenate the table names, so that a complete table_name

But what if I need to separate the name table or the email?

Then you need to use MD5 to encrypt because the encrypted MD5 number is in hexadecimal, so you can take the remainder, the idea is the same as above.

Vertical table:

Why is vertical partitioning necessary?

Because if there is a large field in a table that does not need to be displayed or is not currently needed, then even if it is not deliberately queried, when querying based on ID or other indexes, the large field will be found together, which will seriously affect the query performance. Therefore, vertical partitioning is used.

Please see the following figure for details:

The above is an idea of ​​horizontal and vertical table division. Please point out any shortcomings. Thank you.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM. If you want to learn more about this, please check out the following links

You may also be interested in:
  • How to store text and pictures in MySQL
  • Installation and use of mysql on Ubuntu (general version)
  • The pitfalls encountered when nodejs synchronously calls to obtain mysql data
  • How to add indexes to MySQL
  • Alibaba Cloud ESC Server Docker Deployment of Single Node Mysql
  • Summary of the differences between MySQL storage engines MyISAM and InnoDB
  • Several solutions for forgetting the MySQL password
  • Tomcat+Mysql high concurrency configuration optimization explanation
  • Why does MySQL database index choose to use B+ tree?
  • Several ways to store images in MySQL database

<<:  How to use native JS to implement touch sliding monitoring events

>>:  How to run top command in batch mode

Recommend

Getting Started Guide to MySQL Sharding

Preface Relational databases are more likely to b...

Sample code for configuring nginx to support https

1. Introduction Are you still leaving your websit...

How to implement the prototype pattern in JavaScript

Overview The prototype pattern refers to the type...

CSS perfectly solves the problem of front-end image deformation

I saw an article in Toutiao IT School that CSS pe...

Vue implements the magnifying glass function of the product details page

This article shares the specific code of Vue to i...

Vue implements a simple timer component

When doing a project, it is inevitable to encount...

Solution to 1045 error when navicat connects to mysql

When connecting to the local database, navicat fo...

A brief discussion on CSS cascading mechanism

Why does CSS have a cascading mechanism? Because ...

Tutorial on deploying nginx+uwsgi in Django project under Centos8

1. Virtual environment virtualenv installation 1....

Detailed explanation of mysql basic operation statement commands

1. Connect to MySQL Format: mysql -h host address...

Detailed instructions for installing mysql5.7 database under centos7.2

The mysql on the server is installed with version...

Example of how to reference environment variables in Docker Compose

In a project, you often need to use environment v...

Practical record of solving MySQL deep paging problem

Table of contents Preface Why does limit deep pag...