A joint survey of several big data scales

During the interview today, the interviewer asked a question, table a 100W, table b 500W. If table an and table b are checked together, the query speed is very slow, how to optimize it?

the interviewer said the index was perfect. I didn"t answer at that time.

Aug.13,2021

1, first of all, explain looks at the execution order of mysql and whether there is a "perfect" index used correctly;
2, then when it comes to 100w and 500w, see if the result is a small table driving a large table, if not, use a STRAIGHT_JOIN association to force the driver table to try;
3, see whether deferred queries can be used to override the index
.
personal opinion is not quite sure of the interviewer's intention, but the explain analysis must be


you can take a look at the following optimization ideas.
mysql two tables association optimization

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-1b374a4-2adc6.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-1b374a4-2adc6.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?