MySQL how to achieve sub-library sub-table, how to improve query efficiency

I have not done business platform, but to understand them round after round, and today nothing else, talk round after round them. I want to start this show below.

In a large electricity providers websites, with the increase in traffic, the amount of data in the database is growing, this time we will divide the database library sub-table of.

MySQL how to achieve sub-library sub-table, how to improve query efficiency

 

1, how sub-library sub-table?

Two solutions: a vertical split, horizontal split

Vertical Split: split according to the service, such as a plurality of fields may be split into two tables a table, a change often is not, one is often changed.

Split level: i.e., to segment according to Table: for example, the user table can be split into user0,, user1, user2, user3, user4, etc.

2, how to implement the joint inquiry after sub-library sub-table?

You can use a third-party middleware to achieve, such as: mycat, shading-jdbc

Principle Analysis:

When the client sends a sql query: select * from user; middleware based case there are several sub-tables, split into a plurality of statements: select * from user1; select * from user2; select * from user3 query statements and other and the results of the query are returned to the middleware, and then aggregated to the client. These statements are executed concurrently, it would be very efficient, oh.

Guess you like

Origin www.cnblogs.com/mengtaoadmin/p/11184047.html