How to query and insert after mysql divides the table through merge

after dividing the table according to the id model through merge, is the query directly querying the main table? If so, the sub-table will be meaningless! Some people say that through union joint query, then it is estimated that it is not as fast as looking up the main table directly. How do you find out?
also, how do you tell which child table to insert when inserting? I have a headache, do you have a detailed explanation?

Mar.18,2021

A rough idea is not to split the table by id, but to divide the table according to specific query fields.

for example, if you need to query the data of a "date", you can divide the table according to the "month". After you know the date, you can naturally figure out what the month is, and you will know to query that table.
for example, if you need to query the data of a "person's name", you can calculate a hash value according to the person's name, and divide the table according to the first 1 or 2 digits of the hash value. If you want to query a person's data, you can calculate the person's name hash value in advance, and you will know which table that person's data is stored in.

I hope I can help you.


first of all, you need to distinguish the relationship between the table and the table, whether it is one-to-many or many-to-many

.

as you said, if you want to check the job title, it must be an one-to-many relationship, and you naturally need a sub-table

.

for example, the fields in main table An are associated with JobId and sub-table B

For

query, you can use LEFT JOIN to associate with sub-tables

thus query its corresponding title

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b37486-2c079.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b37486-2c079.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?