SELECT
a.*, CONCAT_WS('', parent. NAME, b. NAME) cityName,
CONCAT_WS(
'%',
att.attachment_name,
attachment_url
) attachment,
c. NAME companyName,
d. NAME typeName,
e. NAME stageName,
f. NAME winningBidCompanyName
FROM
bid_info a
LEFT JOIN sys_city_info b ON b. CODE = a.city_code
LEFT JOIN company_info c ON a.company_id =
LEFT JOIN dic_bid_type d ON a.bid_code = d. CODE
LEFT JOIN dic_project_stage e ON e. CODE = a. STATUS
LEFT JOIN company_info f ON a.winning_bid_company_id =
LEFT JOIN sys_city_info parent ON b.parent_code = parent. CODE
LEFT JOIN attach_info att ON att.foreign_key =
AND = '1'
WHERE
1 = 1
ORDER BY
create_time
LIMIT 0,10
就这条sql语句查询速度非常慢
其中对sql进行 explain分析,发现是下面这张表的索引没有生效
LEFT JOIN dic_bid_type d ON a.bid_code = d. CODE
各种分析了网上说的可能有的原因都还是没有解决,最后好像是偶然在哪儿看到说
数据库中的数据太少也会导致索引失效
结果真的是这个原因,因为我这张表数据库里面就四条数据,增加了几条多余数据过后索引就生效了。