O
O
Optimus2017-08-22 15:34:29
MySQL
Optimus, 2017-08-22 15:34:29

How to read SQL query?

Request example:

SELECT * FROM `table1` 

RIGHT JOIN `table2` 

ON `table2`.`uid` = `table1`.`uid`  

LEFT JOIN `table3` 

ON `table1`.`uid`  = `table3`.`uid`  

WHERE `table2`.`acc_id` = 11

AND `table1`.`data` IN (...)

This is: give all records from table t2 but only those that are from the specified IN list in t1 and also from t2 select only those that are in t3 whose uid matches t1?
Those. the main table in this query is t2? And data is selected from it depending on those that are "left" and "right" in other tables?
What is the order of execution of this and similar requests? How to understand how to optimize it, probably at first it makes sense to select data from tables in which there is the least data?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0X12eb, 2017-08-22
@0X12eb

You need to read about Execution Plan in mysql.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question