我想减少我的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的LEFT JOIN。并从不喜欢的测试切换到!=。 – jarlh
我试图改变不喜欢!=但它是一样的,但我删除嵌套的查询和它的工作,所以问题来自休息的查询... 我的表globe_statistique:56000行 – Gabi
你的意思是,第一个SELECT是慢的吗? – jarlh