The EXPLAIN statement is a very useful tool in SQL databases to help users better understand what's going on in queries and where to apply tweaks. For example, the output of EXPLAIN can help you decide where to add indexes and can quickly remedy slow queries by telling you the join type, the possible indexes to choose vs. the index actually chosen, the estimate of rows to be examined, etc.
How do you use EXPLAIN?
Simply put the keyword EXPLAIN in front of the query to be analyzed. EXPLAIN can be used in front of a query beginning with
EXPLAIN SELECT * FROM t1 WHERE t1.id = 12345 OR t1.LastName = 'Something';
The output will look like below:
For more information, you can refer to: https://dev.mysql.com/doc/refman/8.0/en/explain.html