Some understandings of understanding mysql_ sub-database and sub-table

Vertical segmentation:
    Vertical sub-table: Split the fields in the original table into multiple tables
    Vertical sub-library: Prevalent in microservices, each business subsystem has its own independent database.
                   Advantages: clear structure
                   Disadvantages: increase the complexity of the system, requiring each system to expose the interface.

Horizontal split:
       Horizontal split table: The table structure is consistent. Divide the original records into multiple tables with the same structure according to certain rules. It is usually implemented by hash modulo.
       Horizontal sub-database sub-table: Split the same table structure into different databases.

Problems and solutions brought by sub-database and sub-table:
  ● The problem of primary key id
            adopts the id generation rule of single database and single table, and the situation of primary key conflict will occur. That is to take into account the index performance, but also consider the unique. The usual methods are as follows:
            1. Use redis to generate a globally unique primary key id
            2. Use 64-bit UUID as the unique primary key
            Method 2 takes up a lot of space and is not recommended.
            Considering the routing, the machine id needs to be included in the primary key information.
  ● join query question
            list query does not display the total number of pages, nor does it perform union of multiple tables, but only query the record information of a certain table.
            For record details query, it needs to be adapted at the application code level, and according to the primary key id to locate which device to find data on. The premise is that the primary key id needs to contain the machine id.
  ● Transaction Control Issues
            Control transactions by means of two-phase commit. When it comes to service provisioning, it is necessary to pay attention to the idempotent control of service provisioning.
  ● For report statistics,
              the current popular practice is offline analysis and stream computing to generate reports based on templates.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326198486&siteId=291194637