나는 내 SQL 요청의 처리 시간을 줄이고 싶다. (실제로는 10 분 정도 걸린다.) 중첩 된 SQL 쿼리에서 문제가 발생한다고 생각한다. 이 시도SQL 요청이 너무 길어 ... 단순화하는 방법?
SELECT DISTINCT `gst.codeAP21`, `gst.email`, `gst.date`, `go.amount`
FROM globe_statistique
JOIN globe_customers ON `gst.codeAP21`=`gc.codeAP21`
JOIN globe_orders ON `gc.ID`=`go.FK_ID_customers`
WHERE `gst.page` = 'send_order'
AND `gst.date` = FROM_UNIXTIME(`go.date`,'%%Y-%%m-%%d')
UNION
SELECT DISTINCT `gst.codeAP21`, `gst.email`, `gst.date`, '-'
FROM globe_statistique
WHERE `gst.page` NOT LIKE 'send_order' "
AND (`gst.codeAP21`,`gst.date`) NOT IN
(SELECT `gst.codeAP21`,`gst.date` FROM globe_statistique
WHERE `gst.page`='send_order');
감사
NOT IN 재 - 쓰기 끝으로 그룹은 동일한 결과를 제공합니다. 그리고 NOT LIKE에서! =로 테스트 스위치를 전환하십시오. – jarlh
필자는 좋지 않음으로 변경하려고 시도하지만! = 같지만 중첩 된 쿼리를 제거하면 작동합니다. 내 테이블 globe_statistique : 56000 rows – Gabi
즉, 첫 번째 SELECT 느린 것입니까? – jarlh