mysql 쿼리 133개 불러오는데 1분... ㅠ.ㅜ
$sql = "
select c.ca_id, c.it_start, c.it_icon, c.it_id, c.it_name, c.it_id as pid, c.it_info1, c.it_info2, c.it_info3, it_icon, c.it_s_air, c.it_tour1, c.it_tour2,
a.prc_exchange, a.prc_halin, a.prc_price11, a.prc_price21, a.prc_price31,
(select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1) as price,
CASE a.prc_exchange
WHEN 'KOR'
THEN (select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1)
WHEN 'JPN'
THEN CAST((((select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1)
* round((select ex_JPY1 from exchange order by ex_regdate DESC LIMIT 1)/100) ) * 100 ) AS UNSIGNED)
WHEN 'USD'
THEN CAST((((select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1)
* round((select ex_USD1 from exchange order by ex_regdate DESC LIMIT 1)/100) ) * 100) AS UNSIGNED)
WHEN 'CHN'
THEN CAST((((select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1)
* round((select ex_CNY1 from exchange order by ex_regdate DESC LIMIT 1)/100) ) * 100) AS UNSIGNED)
WHEN 'ERP'
THEN CAST((((select CAST(prc_price11 AS UNSIGNED) AS LOWPRIC from wiz_prdprice where prc_price11>0 AND it_id = pid group by it_id order by LOWPRIC asc LIMIT 1)
* round((select ex_EUR1 from exchange order by ex_regdate DESC LIMIT 1)/100) ) * 100) AS UNSIGNED)
END SUM
from wiz_prdprice as a, exchange as b, wiz_product2 as c
WHERE 1=1
AND c.it_id = a.it_id
AND a.prc_price11 > 0
AND it_use != 'N'
$catcode_sql
GROUP BY c.it_id
$order_sql
limit $start, $rows
";
위 쿼리를 돌리면
133개 밖에 안되는 데이타를 가져오는데 1분 여 걸립니다.
이걸 최적화 하려면 어떻게 해야 할까요 ?
ㅠ.ㅜ
답변 1개
답변을 작성하려면 로그인이 필요합니다.