MYSQL assumes master-slave replication and sub-library and sub-table, which is bound to increase the difficulty of the code. How to solve this?

  ios, question

For example, query. If MYSQL is divided into libraries and tables, it will definitely increase the difficulty of logic code. For example, a simple query, after dividing the tables, first find the table and then query. This will multiply the complexity of the code. . . . How should we design and solve this problem? ? ? ? ? ? ? ? ? ? ? ?
PS: I am inexperienced. The current level is above mysql. I found that the logic code will become much more complicated once the library is divided into tables.

This has been discovered by you, but there is really no better way. …

1, respectively inquiring, obtaining results, and then Merge sort in memory
2, storing the above results in an intermediate table

Isn’t this MapReduce