1000 select queries vs 1 ( select .. in ) query
Hello.
I have just read about N+1 queries problem. So I have the doubt about the performance of 2 ways.
The way 1: I have 1000 queries like that:
select * from topic where user_id = 1
select * from topic where user_id = 2
...
select * from topic where user_id = 1000
I supposed the topic table has 1.000.000 rows and each query uses binary search, so I think the Big O's way is: 1000 * log2(1.000.000)
The way 2: I have 1 query:
select * from topic where user_id in (1,2,..., 1000)
I don't know the algorithm of 2nd way. So can you explain me the algorithm of (select .. in) query. Is there any case the 1st way is better than 2nd way?
Subject
Views
Written By
Posted
1000 select queries vs 1 ( select .. in ) query
707
May 04, 2021 10:15AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.