有没有人有关于如何测试大量数据集的最佳实践?
例如,我有一个运行此SQL的报告页面:
SELECT COUNT(DISTINCT order_items.id) AS order_items,
DATE(order_items.created_on) AS date
FROM orders
JOIN order_items ON order_items.order_id = orders.id
JOIN shipments ON shipments.id = order_items.shipment_id
JOIN transactions ON transactions.order_id = orders.id
JOIN customers ON customers.id = orders.customer_id
LEFT JOIN flagged_transactions ON flagged_transactions.transaction_id = transactions.id
WHERE orders.state NOT IN ('a', 'b', 'c', '')
AND customers.state NOT IN ('fraud', 'maybe_fraud')
AND shipments.state NOT IN ('cancelled', 'shipped')
AND shipments.vendor_id = %{some_vendor}
AND order_items.quantity > 0
AND order_items.state IN ('initial', 'approve')
AND order_items.created_on BETWEEN %{start_date} AND %{end_date}
AND (flagged_transactions.id IS NULL OR flagged_transactions.state NOT IN ('pending'))
GROUP BY date
ORDER BY date
在一个规范中,这成了一大堆工厂,每个对象有一个或几个。
有没有人有关于如何更优雅地做到这一点的想法或最佳实践?
答案 0 :(得分:1)
您可以采用的几种技术: