This query:
<code>select id
from user u
where u.account_id = 600
</code>
<code>select id
from user u
where u.account_id = 600
</code>
select id
from user u
where u.account_id = 600
returns:
<code>61,71,68,69,70,118,116,117,248,381,384,325,265,393
</code>
<code>61,71,68,69,70,118,116,117,248,381,384,325,265,393
</code>
61,71,68,69,70,118,116,117,248,381,384,325,265,393
and it works really fast. This query:
<code>select *
from logs l
where l.user_id in
(
61,71,68,69,70,118,116,117,248,381,384,325,265,393
)
</code>
<code>select *
from logs l
where l.user_id in
(
61,71,68,69,70,118,116,117,248,381,384,325,265,393
)
</code>
select *
from logs l
where l.user_id in
(
61,71,68,69,70,118,116,117,248,381,384,325,265,393
)
works really fast too. But why is this query:
<code>select *
from logs l
where l.user_id in
(
select id
from user u
where u.account_id = 600
)
</code>
<code>select *
from logs l
where l.user_id in
(
select id
from user u
where u.account_id = 600
)
</code>
select *
from logs l
where l.user_id in
(
select id
from user u
where u.account_id = 600
)
works very slow (Im getting timeout). Why putting explicit data is solving the problem?