用like  速度也会很慢的

解决方案 »

  1.   

    加order by jobdate當然會慢﹐如果再加排序一個字段還要慢﹐應該加個索引
      

  2.   

    查询大部分都会用到like的。否则意义不大。
    我就不明白为什么别人会那么快,看别人的网站,查询速度都听快的。我的数据也不多,就20万。
    难道是我的ms sql有问题。
      

  3.   

    jobdate是递增的吗?你的id是不是递增字段?是不是主键?
    看看是否可以用 order by id
      

  4.   

    我也想过了用order by id,速度快了很多。但我不能用它,只能按时间顺序。我也加了索引,效果不好。
      

  5.   

    在 jobdate 上建立聚集索引
      

  6.   

    (( jobtitle like '%developer%') or ( jobtitle like '% IT %') or ( jobtitle like '%programmer%')) and    charindex('ON'  collate  chinese_prc_CS_AI,jobLocation)>0这个like 检索不好,加索引也没有用,建议配置全文检索实现这种检索
    全文配置参考我的帖子
    http://community.csdn.net/Expert/topic/3295/3295983.xml?temp=.5507471or 条件也是影响效率的因素之一
    如果可能的话,建议增设关键字段,将 developer/IT 之类的,从 jobtitle 中分离出来
      

  7.   

    如果只是加了order by 变慢了很多,那么改成这样试试:
    select * from
    (
    select top 300 id,jobDetail,Cast(joblink As text)joblink,jobTitle,joblocation,jobWebsite,jobCache,convert(varchar(20),jobpostDate,110) as jobdate from joblist where (( jobtitle like '%developer%') or ( jobtitle like '% IT %') or ( jobtitle like '%programmer%')) and    charindex('ON'  collate  chinese_prc_CS_AI,jobLocation)>0
    ) t order by jobdate desc仅对300条排序应该快些
      

  8.   

    都没注意到?
    convert(varchar(20),jobpostDate,110) as jobdate   和
    order by jobdate desc
    这样加索引也没用
    不如把
    order by jobdate desc
    改成
    order by jobpostDate desc
    不过次序和原来有所不同,搂主自己考虑能不能改,如果能改,在jobpostDate字段加索引应该有用。再说你的语句:
    where (( jobtitle like '%developer%') or ( jobtitle like '% IT %') or ( jobtitle like '%programmer%')) 
    and    charindex('ON'  collate  chinese_prc_CS_AI,jobLocation)>0
    这个条件有没有可能优化?这个条件可是什么索引都用不到,数据多了肯定慢
      

  9.   

    按 pbsql(风云) 的做法出错:
    在工作表中只允许有 text 指针,而决不允许有 text、ntext 或 image 列。查询处理器生成的查询计划要求在工作表中有 text、ntext 或 image 列。
    Yang_(扬帆破浪) 的不如把
    order by jobdate desc
    改成
    order by jobpostDate desc
    效果一样,没什么差别。
    我查询是肯定要用到like的,只能用模糊查询。
      

  10.   

    如果效果一样,那在jobpostDate字段加索引试试既然你只能这么查询,我想速度也不会得到质的提高,只能保持这个表的数据不能太多,就是说需要定期把过时数据转移到历史表,想不到别的方法