table1有字段 name,password,email
select * from table1 t where substr(t.name,1,4)= 'mitt';

解决方案 »

  1.   

    select * from table1 t where t.name LIKE   'mitt%';
    给name创建index:create index i_name on table1 (name);
      

  2.   

    用不用把* 列成
    name,password,email
      

  3.   

    常用的话建个
    substr(t.name,1,4)的索引列
      

  4.   

    select * from table1 t where t.name LIKE   'mitt%';
    给name创建index:create index i_name on table1 (name);
      

  5.   

    1楼正解,能不用函数的,就不用函数,如果在name列有索引,使用函数将不会使用name列的索引,而走全表扫描,即使没有索引,执行substr函数也不需要。
      

  6.   

    select * from table1 t where t.name like 'mitt%';
    优化效果不明显,
    测试
    select count(*) from table1 t where substr(t.name,1,4)= 'mitt'; --2.08
    select count(*) from table1 t where t.name like 'mitt%'; --1.57
    300w数据量,再想别的