select * from tablename where aa like '%关键字%' order by id desc
--方式好象要全表扫描,试下:
select * from tablename where aa like '关键字%' order by id desc
--id 字段也建索引.

解决方案 »

  1.   

    由于应用的需要,必须在 aa 里面任意匹配我现在想不通的是,为什么 aa 建索引反而比不建更消耗时间奇怪了
      

  2.   

    我认为你说的不太清楚Create table aa(id int identity(1,1),aa varchar(10))alter table aa add constraint PK_AA_ID primary key(id)insert into aa 
    select '1111' union all
    select '2222' union all
    select '2222' union all
    select '2222' union all
    select '2222' union all
    select '2222' union all
    select '2222' union all
    select '关键字' select * from aa where aa like '%关键字%' order by id desc
    这个时候用的是索引
    然后在aa上建立非聚集索引查询成本也用的是索引阿