In the development of last year, with the increase of business volume, thus appeared concurrency, query data pressure increase, single table increase field difficulties and other problems, so the implementation of reading and writing separation and table and database, the chicken is very honored to participate in, under the leadership of the big man learned a lot of knowledge, such as: To deal with the synchronization of new and old environment data, how to gracefully transition online, how to divide granularity to the smallest extent to avoid problems and so on, the following conclusions are made.
1. What is sub-table and sub-library?
As the name implies, the data stored in one database is scattered across multiple libraries, and the data stored in one table is scattered across multiple tables.Copy the code
2. When do we need separate tables and libraries?
Ali statute recommends:Copy the code
When a database is created, as time goes by and the volume of services increases, the number of tables in the database and the amount of data in the table will increase, and two disadvantages may occur:
A: The storage resources of the database are limited, and its load capacity is also limited. The massive accumulation of data will definitely lead to the decline of its ability to process data. B: The more data there is, the higher the cost of adding, deleting, modifying, and checking the data will be.Copy the code
Note: Some people would argue that data processing is slow, so consider indexing…..
Ep: Try indexing a 120 million table to see if you can optimize it? Add a field (......) to the table in the online process Consequences dare not think of, for this system to do sub-table sub-table, the following introduces the common sub-table sub-libraryCopy the code
3. Division method of sub-table and sub-library
level
Vertical division
In the same way, the so-called vertical partition means that infrequently used fields are divided into other tables by primary key association because there are too many fields in the table to improve performance. After vertical partitioning, the characteristics of each table are as follows: a: Each table has a different structure; B: Tables are associated with each other through primary keys.
I am not just, in front of you only wish to humiliate with your companion, if the article is improper, hope big guy give directions or two; If I help you, also hope you can share, thumb up growth is a bitter practice alone, I really need your accompany and support, this is also I to go on the fundamental motivation, let us in the growth of the company to witness each other at the same time can infect beside the person closest to grow together, I in this KouXie!