下面是我的查询2 LEFT JOIN
$customers_query_raw = "select
c.*, c.customers_shopping_points as c_points,
a.entry_state, a.entry_zone_id, a.entry_country_id,
ci.customers_info_date_account_created,
cc.credit from " . TABLE_CUSTOMERS . " c
left join " . TABLE_ADDRESS_BOOK . " a on c.customers_id = a.customers_id and c.customers_default_address_id = a.address_book_id
left join ".TABLE_CUSTOMERS_CREDIT." cc on c.customers_id = cc.customer_id
, " . TABLE_CUSTOMERS_INFO . " ci
where (c.customers_type = 0 or c.customers_type = 1 or c.customers_type = 2) and ci.customers_info_id = c.customers_id
order by ".$order;
结果仅在43.53秒后显示(非常慢),但如果我删除此行
left join ".TABLE_CUSTOMERS_CREDIT." cc on c.customers_id = cc.customer_id
结果将在1.61秒后显示(正常),并确定此行是主要问题。
下面是TABLE_CUSTOMERS_CREDIT
的表结构Column Type
customers_credit_id int(11)
customer_id int(11)
credit decimal(15,2)
date_added datetime
last_modified_by int(11)
comment varchar(255)
order_id int(11)
我的索引是customers_id