query tuning(2) 2분 -> 1초 미만

joojong·2023년 9월 13일
0

쿼리튜닝

목록 보기
2/3

기존 쿼리

select 
i.idx as idx
, i.address as address
, i.address_a as addressA
, i.address_n as addressN
, i.created_at as createdAt
, di.title
from (
   select 
   no
   , pk
   from config c
   where c.pk = 27
) c
left outer join delivery_info di on di.no = c.pk
left outer join info i on c.no = i.pk
order by i.created_at desc
limit 10;

튜닝한 쿼리

select
i.idx as idx
, i.address as address
, i.address_a as addressA
, i.address_n as addressN
, i.created_at as createdAt
, di.title
from info i
left join config c on c.no = i.pk
left join delivery_info di on di.no = c.pk
where i.pk in (
   select
   no
   from delivery_info di
   where di.configPk = 27
)
order by i.created_at desc
limit 10;
profile
Back-end developer

0개의 댓글