获取记录超过30000后,Mysql脚本卡住了

时间:2014-01-30 10:20:46

标签: mysql database

我需要一次获取50000条记录,因为我不能使用限制,因为我需要将记录从商店同步到crm。目前,如果我一次拨打20000条记录,这很好,但如果超过30000,则不是。

SELECT order_num, o.uid AS uid, o.create_date AS create_date, shipping_name, shipping_company, shipping_address1, shipping_address2, shipping_city, shipping_state, shipping_province, shipping_zip, shipping_country
    FROM orders o LEFT JOIN users u ON o.uid = u.uid
    WHERE o.status = 'Completed'

我正在运行此查询,结果超过50000条记录。因为我使用API​​将这些记录同步到另一个CRM,所以在运行脚本时,它显示空白页面...另外,如果我使用LIMIT 0,20000 ..它运行良好

Plz建议我..谢谢

1 个答案:

答案 0 :(得分:0)

你可以尝试

SELECT order_num, o.uid AS uid, o.create_date AS create_date, shipping_name, shipping_company, shipping_address1, shipping_address2, shipping_city, shipping_state, shipping_province, shipping_zip, shipping_country
    FROM orders o LEFT JOIN
    ( SELECT * FROM users WHERE o.status = 'Completed' ) as u
 ON o.uid = u.uid

这可以减少加入时间