select a.* from a表 a left join b表 b on b.a_name=a.name where a.ctime<='".$now."' and state=1 and b.a_name is null 在CTIME、NAME建立索引,不是复合索引
显示行 0 - 29 (32 总计, 查询花费 109.7145 秒) SQL 查询: SELECT customers_name, web_id, customers_email_address, id FROM ec_customers c WHERE customers_info_date_account_created <= '1350792014' AND STATUS =1 AND NOT EXISTS (SELECT * FROM ec_orders WHERE customers_email_address = c.customers_email_address ) LIMIT 0 , 30
显示行 0 - 29 (32 总计, 查询花费 111.5491 秒) SQL 查询: SELECT c.customers_name, c.web_id, c.customers_email_address, c.id FROM ec_customers c LEFT JOIN ec_orders o ON o.customers_email_address = c.customers_email_address WHERE c.customers_info_date_account_created <= '1350792014' AND c.status =1 AND o.customers_email_address IS NULL LIMIT 0 , 30
显示行 0 - 29 (32 总计, 查询花费 117.9760 秒) SQL 查询: SELECT c.customers_name, c.web_id, c.customers_email_address, c.id FROM ec_customers c LEFT JOIN ec_orders o ON o.customers_email_address = c.customers_email_address WHERE c.customers_info_date_account_created <= '1350792014' AND c.status =1 AND o.customers_email_address IS NULL LIMIT 0 , 30 分别建索引也是很慢 117秒
在CTIME、NAME上建立索引没有
from a表 a left join b表 b on b.a_name=a.name
where a.ctime<='".$now."' and state=1 and b.a_name is null
在CTIME、NAME建立索引,不是复合索引
SQL 查询:
SELECT customers_name, web_id, customers_email_address, id
FROM ec_customers c
WHERE customers_info_date_account_created <= '1350792014'
AND STATUS =1
AND NOT
EXISTS (SELECT *
FROM ec_orders
WHERE customers_email_address = c.customers_email_address
)
LIMIT 0 , 30
SQL 查询:
SELECT c.customers_name, c.web_id, c.customers_email_address, c.id
FROM ec_customers c
LEFT JOIN ec_orders o ON o.customers_email_address = c.customers_email_address
WHERE c.customers_info_date_account_created <= '1350792014'
AND c.status =1
AND o.customers_email_address IS NULL
LIMIT 0 , 30
SQL 查询:
SELECT c.customers_name, c.web_id, c.customers_email_address, c.id
FROM ec_customers c
LEFT JOIN ec_orders o ON o.customers_email_address = c.customers_email_address
WHERE c.customers_info_date_account_created <= '1350792014'
AND c.status =1
AND o.customers_email_address IS NULL
LIMIT 0 , 30
分别建索引也是很慢 117秒