V2EX-求助:sql 优化。

ffw5b7: 之前发错节点了。

select
r.uuid as recruitUuid,
r.project_name as projectName,
r.work_type as workType,
r.user_name as name,
r.certification_status as certificationStatus,
r.team_status as teamStatus,
r.user_phone as userPhone,
r.recruit_num as invite,
r.price as price,
r.description as description,
r.detail_site as projectAddress,
r.create_time as createTime,
r.top_flag as topFlag,
r.release_type as releaseType,
r.bind_phone as bindPhone,
r.is_help_wanted as isHelpWanted,
r.modify_time as modifyTime
from
recruit r
where
r.del_flag = 0
order by
r.top_flag desc ,
(
case
r.is_help_wanted when '1' then 0
else 1
end ) asc,
LOCATE('深圳市', detail_site) desc,
LOCATE('广东',detail_site) desc,
r.create_time desc
limit 100

is_help_wanted 和 detail_site 怎么建立索引。或者怎么优化关于这二个字段的排序?

CREATE INDEX index_order_by ON recruit (
top_flag DESC,
is_help_wanted,
detail_site,
create_time DESC
);

is_help_wanted,detail_site 导致失效, 谷歌搜了下 LOCATE 没有关于 LOCATE 索引方面的,

本文地址:https://niul.net/662.html
牛C网:https://niuc.net
零九导航:https://09.gay
牛C网导航:https://9i1.net
福利APP中心:https://app.niuc.net
福利APP合集:https://niuc.net/share/1678.html
THE END
分享
二维码
< <上一篇
下一篇>>