日期:2014-05-16  浏览次数:20755 次

10万数据的排序,无索引,如何把时间缩短到半分钟以内?
select a.*,
  (case when a.col1 like '%?%'
  then ? else ?) as score1,
  (case when a.col2 like '%?%'
  then ? else ?) as score2,
  (case when a.col3 like '%?%'
  then ? else ?) as score3,
  .....
  .....
  (case when a.col12 like '%?%'
  then ? else ?) as score12

from A a
order by (score1+score2+.......score12)



?是动态传入的值,由页面输入。如何优化这条sql。我怎么都觉得没什么可能。但是需求还不能变,无奈啊。
是不是需要改变算法。求大神。

------解决方案--------------------
无索引,like语句,有点坑爹啊,里面有BLOB字段么?我先想想!
------解决方案--------------------
你直接order by decode()試試看
------解决方案--------------------
不好优化,不知道你的需求是不是计分排序.如果是的话可以把你的表结构.和大体需求描述一下,看看能不能重新设计一下.