求助:sql 优化

2021-05-31 15:36:48 +08:00
 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 怎么建立索引。或者怎么优化关于这二个字段的排序?
499 次点击
所在节点    问与答
1 条回复
ffw5b7
2021-05-31 15:43:06 +08:00
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 索引方面的,

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/780364

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX