I was wondering how join and where apply when MySQL query statement runs.
[Example]
- query:
select a.id, a.name, b.id from a left join b on a.b_id = b.id where a.name = 'cale' and b.no = 10
- Number of data: 100 for a and 3000 for b
- Indexes are applied to a.name and b.no
- Number of data according to conditions: 10 for conditions a (a.name = ‘cale’), and 20 for conditions b (b.no = 10)
[Question]
- Is join and where clause applied in the order I think below?
- Table A located in from access to the driving table
- Find the scale that is the condition of the table A. Extract 10 out of 100 results here
- Access table B, which is a driven table
- Find no, which is the condition of B. Extract 20 out of 3000 results here
- 10*20 = 200 loops in total
- Or if i look for the data, the processing order is usually from -> join -> where …
then I read the table as many as 100(a)*3000(b) first, and then I wonder if the where clause is applied as a filter.
I am curious about the order of processing the query.
New contributor
jinwoo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.