Answer the question
In order to leave comments, you need to log in
Are these queries fast?
Guys, tell me if there is a difference in efficiency in these two queries, and if so, what is it? what request on idea should work faster?
first request
select *
from Table1 t1 inner join (select tt.someId from TestTable tt where tt.id > 100) t2 on t1.someId = t2.someId
where t1.id > 1000
select *
from Table t1 inner join TestTable t2 on t1.someId = t2.someId
where t1.id > 1000 and t2.id > 100
Answer the question
In order to leave comments, you need to log in
For a normal scheduler, the behavior specifically for these two requests should be the same. In any case, before the nested join loop, you will need to filter the rows of both tables by indexes. Because The filtering conditions for both tables are independent, I can't even think of how to run the queries differently.
In general, the second option is much clearer for both the programmer and the DBMS (it is easier to build an execution plan).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question