SELECT a+b,c,d,e,f,g FROM table_1 WHERE a='sdfsdfaf' and b='sf'

解决方案 »

  1.   

    SELECT a+b,c,d,e,f,g FROM table_1 WHERE b='sf' and  a='sdfsdfaf'
      

  2.   

    Not exactly!
    Personally, I think it is largely depend on the implementation of your DBMS as well as the configuration of your individual DB.Whats your DBMS anyway?
      

  3.   

    先说明是那个DBMS? 数据库的结构才是取决最大因素.
    一般情形下, 在'where'条件中的字段是有索引的, 都会较快,用DBMS中的Stored Procedures, 会比你用前端Query作同一个sql为快.
      

  4.   

    如果你在ab上都作过索引的话
    SELECT a+b,c,d,e,f,g FROM table_1 WHERE a='sdfsdfaf' and b='sf'
    这个效率会高些。
      

  5.   

    第一条快。
    SELECT a+b,c,d,e,f,g FROM table_1 WHERE a='sdfsdfaf' and b='sf'
    不论是否建索引,系统都可以自己在找到a='sdfsdfaf'的记录集内找b='sf'的记录;
    而第二条,无论如何都几乎要查找到每一条记录,并且计算a+b的值
    几乎没有什么优化的余地。
    如果在a,b上或者更多字段上建立索引,1可以更好地减少工作了。
      

  6.   

    the first one is not equivalent to the second one ah!
    They are two different queries!For the second one, Oracle supports index on functions, so it's still possible to be indexed.
    so if you have index on a+b, but no index on a or b, then the 2nd is faster.