MYSQL assumes that master-slave replication and database/table sharding are difficult to code! How can this be solved?

Source: Internet
Author: User
For example, query. If MYSQL is used for database/table sharding, the logic code is more difficult. For example, in a simple query, you need to find the table after dividing the table and then query it. In this way, the complexity of the Code will multiply .... How can we design and solve this problem ??????????... For example, query. If MYSQL is used for database/table sharding, the logic code is more difficult. For example, in a simple query, you need to find the table after dividing the table and then query it. In this way, the complexity of the Code will multiply .... How can we design and solve this problem ????????????
PS: I have insufficient experience. The current level is a mysql. I found that the logic code will become much more complicated after database/table sharding.

Reply content:

For example, query. If MYSQL is used for database/table sharding, the logic code is more difficult. For example, in a simple query, you need to find the table after dividing the table and then query it. In this way, the complexity of the Code will multiply .... How can we design and solve this problem ????????????
PS: I have insufficient experience. The current level is a mysql. I found that the logic code will become much more complicated after database/table sharding.

You have discovered this, but there is no better way...

1. query the results separately, and then merge and sort the results in the memory.
2. Store the above results to the intermediate table

Isn't that MapReduce?

For example

Suppose there is a fielduser_id, You canuser_idThe last few digits are used for database/table sharding:

| User_id | name |
| 123456 | db_45.table_45_6 |
| 654321 | db_32.table_32_1 |

Simple

You can try partitioning...

How to split tables? Why not directly use the partition technology added after mysql5.1...

It is not as difficult as you think. It is just an extra operation to obtain and indicate before the operation table. It is good to encapsulate a function.
The real difficulty lies in the data statistics, which is what @ vus520 said.

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.