查询优化以避免长时间运行

时间:2018-02-22 10:03:56

标签: mysql sql

select tlb.player_id,device_gcm_id
from st_pms_transaction_master ps
right join (
    SELECT pm.player_id,device_gcm_id,device_version
    FROM st_pms_player_device_version_master dvm
    INNER JOIN st_pms_player_master pm ON dvm.player_id=pm.player_id
    inner join st_pms_device_master device on device.device_id=dvm.device_id  
    WHERE pm.status='ACTIVE'  AND device_gcm_id IS NOT NULL) tlb
on ps.player_id=tlb.player_id where transaction_date <= '2018-02-27 00:00:00.0' and tlb.player_id not in (
    select player_id
    from st_pms_transaction_master
    where transaction_date >= '2018-02-27 00:00:00.0'
   , group by player_id)
group by ps.player_id

实际上查询是正确的,但我想优化它,因为需要很长时间才能执行10分钟。所以我正在努力,但需要一些简单的建议!

0 个答案:

没有答案