select id,firstname,lastname,email,country,portal,language
from totaluser
where userid in
(select user from (select user, shipping / NULLIF(goodsvalue,0) as difference
from shipment
where user in
(select user
from (select user, count(*) as shipcount
from shipment
where user in
(select user from shipment
where status in ('3','5')
and createdtime between '2012-01-01'
and '2013-02-22' group by user)
and status in ('3','5') group by user)
as a
where status in ('3','5')
and shipcount=1))
as b
where difference > 2.5);
これは非常に単純なステートメントであり、テストサーバーではすぐに実行できることを理解していますが、本番サーバーで実行するには永遠に時間がかかります。スピードアップするにはどうすれば変更できますか?