이 쿼리 느리지 않을까요?...

· 14년 전 · 1548
SELECT od_id,
SUBSTRING_INDEX(od_addr1,' ',$len) as od_addr1,
mb_id,
od_name,
`$g4[yc4_order_table]`.on_uid,
sum(od_send_cost) as od_send_cost,
sum(od_receipt_bank) as od_receipt_bank,
sum(od_receipt_card) as od_receipt_card,
sum(od_receipt_point) as od_receipt_point,
sum(od_dc_amount) as od_dc_amount,
(sum(od_receipt_bank + od_receipt_card + od_receipt_point)) as receiptamount,
(sum(od_refund_amount + od_cancel_card)) as receiptcancel,
sum(orderamount) as orderamount,
sum(ordercancel) as ordercancel

from $g4[yc4_order_table]

LEFT JOIN (
SELECT on_uid,
sum(ct_amount * ct_qty) as orderamount,
sum(IF(ct_status = '취소' OR ct_status = '반품' OR ct_status = '품절', ct_amount * ct_qty, 0)) as ordercancel
FROM `$g4[yc4_cart_table]`
WHERE ct_status != '쇼핑'
GROUP BY on_uid
) as $g4[yc4_cart_table] ON `$g4[yc4_order_table]`.on_uid = `$g4[yc4_cart_table]`.on_uid

where SUBSTRING(od_time,1,10) = '$date'

GROUP BY SUBSTRING_INDEX(od_addr1,' ',$len)

order by od_addr1, od_id desc


영카트에서 지역 단위로 매출현황 합산 하는 건데요.
조인에 서브쿼리에... 남발했는데 이거 많이 느릴거 같아서요 ;ㅅ;

조언 부탁드립니다..
|
댓글을 작성하시려면 로그인이 필요합니다. 로그인

그누4 질문답변

그누보드4 관련 질문은 QA 로 이전됩니다. QA 그누보드4 바로가기 기존 게시물은 열람만 가능합니다.

+
제목 글쓴이 날짜 조회
14년 전 조회 1,544
14년 전 조회 992
14년 전 조회 2,487
14년 전 조회 900
14년 전 조회 1,546
14년 전 조회 861
14년 전 조회 1,635
14년 전 조회 944
14년 전 조회 2,052
14년 전 조회 1,549
14년 전 조회 1,523
14년 전 조회 1,688
14년 전 조회 1,144
14년 전 조회 1,659
14년 전 조회 1,072
14년 전 조회 1,527
14년 전 조회 864
14년 전 조회 843
14년 전 조회 1,033
14년 전 조회 1,387
🐛 버그신고