ffw5b7
V2EX  ›  问与答

求助:sql 优化

  •  1
     
  •   ffw5b7 · May 31, 2021 · 861 views
    This topic created in 1808 days ago, the information mentioned may be changed or developed.
    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 怎么建立索引。或者怎么优化关于这二个字段的排序?
    ffw5b7
        1
    ffw5b7  
    OP
       May 31, 2021
    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 索引方面的,
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5961 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 682ms · UTC 02:50 · PVG 10:50 · LAX 19:50 · JFK 22:50
    ♥ Do have faith in what you're doing.