MySQL Sub-table sub-Library analysis

Source: Internet
Author: User

For large-scale Internet applications, the amount of data in a single table can reach tens of millions or even billions of dollars, while facing this high level of concurrency pressure. Master-slave structure can only extend the read ability of the database, write operation or centralized in master, Master does not have the unrestricted hook slave Library, if need to further expand the throughput capacity of the database, you can consider the strategy of using the Sub-Library table.

1. Sub-table

Before dividing the table, the first thing to do is to select the appropriate table strategy (which dictionary is the table field and how many tables to divide the data into) so that the data can be distributed evenly across multiple tables without affecting the normal query. In enterprise applications, org_id (the primary key of the organization) is often used as a table field, which is often a userid in Internet applications. After determining the sub-table strategy, when the data is stored and queried, you need to determine which table to find the data,

Data stored in data table = table field content% number of tables

2. Sub-Library

The Sub-table can solve the problem that the query efficiency of the single-table data is too large, but can not bring the quality improvement to the concurrent access of the database, face high concurrent write access, when Master can not bear the high concurrent write request, no matter how to extend the slave server, there is no meaning. By splitting the database, we improve the ability of the database to write, the so-called sub-Library. The database is routed by using the method of the key word modulo in the sub-Library.

Database in which the data is stored = number of contents of the Library field% database

3. Sub-table and sub-Library

When the database faces both massive data storage and high concurrent access, it is necessary to take both the table and the sub-Library strategy. The General Sub-table sub-library strategy is as follows:

Intermediate variable = keyword% (number of databases * Number of single-Library data tables)

Library = rounding (number of intermediate variables/library data tables)

Table = (middle variable% single-Library data table number)


This article is from the "Dream to Reality" blog, please be sure to keep this source http://lookingdream.blog.51cto.com/5177800/1909284

MySQL Sub-table sub-Library analysis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.