我有这么长时间的问询,应该向我提供一些有关运输的信息,而且它运作良好,但表现得非常糟糕。 装载量大约为4 500米。
SELECT
DATE(paid_at) AS day,
COUNT(*) as order_count,
(
SELECT COUNT(*) FROM line_items
WHERE order_id IN (SELECT id from orders WHERE DATE(paid_at) = day)
) as product_count,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = colissimo
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
) as orders_co,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = colissimo
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
AND paid_amount < 70
) as co_less_70,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = colissimo
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
AND paid_amount >= 70
) as co_plus_70,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = mondial_relais
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
) as orders_mr,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = mondial_relais
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
AND paid_amount < 70
) as mr_less_70,
(
SELECT COUNT(*) FROM orders
WHERE shipping_method = mondial_relais
AND DATE(paid_at) = day
AND state IN ( paid , shipped , completed )
AND paid_amount >= 70
) as mr_plus_70
FROM orders
WHERE MONTH(paid_at) = 11
AND YEAR(paid_at) = 2011
AND state IN ( paid , shipped , completed )
GROUP BY day;
任何想法,我会做什么错做,或我能做些什么? 我有其他类似时间的询问,没有这么多时间来装载。 我认为,这样做的速度将快于例如,每天都有个人询问(在我的方案规划中,而不是在结构上)。