SQL Server Performance

truncate string

Discussion in 'SQL Server 2005 Performance Tuning for DBAs' started by MACUL, Jun 20, 2007.

  1. MACUL New Member

    What is better performance ?

    select * from table1 where field1 = ''
    or
    select * from table1 where len(field1) = 0


    if using rtrim() ?

    www.macul.eti.br

    www.macul.hpg.com.br

    www.primeiramao.com.br
    (ad free)
  2. Madhivanan Moderator


    Any use of function on column wont make use of index if it is defined
    Other than that both will work fine
    Set the execution plan and compare the timings

    Madhivanan

    Failing to plan is Planning to fail
  3. waqar Member

    quote:Originally posted by MACUL

    What is better performance ?

    select * from table1 where field1 = ''
    or
    select * from table1 where len(field1) = 0


    if using rtrim() ?

    www.macul.eti.br

    www.macul.hpg.com.br

    www.primeiramao.com.br
    (ad free)

    If field1 is indexed

    select * from table1 where field1 = '' will use INDEX SEEK
    &
    select * from table1 where len(field1) = 0 will use INDEX SCAN

    Choice is yours.

    Rest as Madhivanan mentioned, compare both execution plan.


    ________________________________________________
    Be great in act, as you have been in thought.
  4. satya Moderator

    I can say both are good at performance wiht smaller volumes, provided you have better indexes, as suggested Execution plan is first hand help for any further betterment.

    Satya SKJ
    Microsoft SQL Server MVP
    Writer, Contributing Editor & Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
  5. waqar Member

    quote:Originally posted by satya

    I can say both are good at performance wiht smaller volumes, provided you have better indexes, as suggested Execution plan is first hand help for any further betterment.

    Satya SKJ
    Microsoft SQL Server MVP
    Writer, Contributing Editor & Moderator
    http://www.SQL-Server-Performance.Com
    This posting is provided AS IS with no rights for the sake of knowledge sharing. Knowledge is of two kinds. We know a subject ourselves or we know where we can find information on it.
    MACUL,
    Note Satya advise with smaller volumes, bigger volume and you will have problem as i mentioned.

    ________________________________________________
    Be great in act, as you have been in thought.

Share This Page